From 73ecc8f25027d1dcbdd5bf04ac9b2d37dda21499 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 25 Jan 2022 17:00:37 +0100 Subject: [PATCH] move ribbon handling after slicing --- src/pipeline.jl | 28 +++++++++++++++------------- test/test_pipeline.jl | 10 +++++++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/pipeline.jl b/src/pipeline.jl index c3a47cca..7808f7b6 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -83,19 +83,6 @@ function _preprocess_userrecipe(kw::AKW) map(kw[:line_z], kw[:x], kw[:y], kw[:z]) end - rib = get(kw, :ribbon, default(:ribbon)) - fr = get(kw, :fillrange, default(:fillrange)) - # map ribbon if it's a Function - if rib isa Function - kw[:ribbon] = map(rib, kw[:x]) - end - # convert a ribbon into a fillrange - if rib !== nothing - make_fillrange_from_ribbon(kw) - # map fillrange if it's a Function - elseif fr !== nothing && fr isa Function - kw[:fillrange] = map(fr, kw[:x]) - end return end @@ -164,6 +151,21 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l end end + for kw in kw_list + rib = get(kw, :ribbon, default(:ribbon)) + fr = get(kw, :fillrange, default(:fillrange)) + # map ribbon if it's a Function + if rib isa Function + kw[:ribbon] = map(rib, kw[:x]) + end + # convert a ribbon into a fillrange + if rib !== nothing + make_fillrange_from_ribbon(kw) + # map fillrange if it's a Function + elseif fr !== nothing && fr isa Function + kw[:fillrange] = map(fr, kw[:x]) + end + end return nothing end diff --git a/test/test_pipeline.jl b/test/test_pipeline.jl index ec864bcf..0d9c116f 100644 --- a/test/test_pipeline.jl +++ b/test/test_pipeline.jl @@ -21,9 +21,13 @@ end @testset "Slicing" begin @test plot(1:5, fillrange = 0)[1][1][:fillrange] == 0 data4 = rand(4, 4) + mat = reshape(1:8, 2, 4) for i in axes(data4, 1) - @test plot(data4, fillrange = 0)[1][i][:fillrange] == 0 - @test plot(data4, fillrange = [1, 2])[1][i][:fillrange] == [1.0, 2.0] - @test plot(data4, fillrange = [1 2])[1][i][:fillrange] == (iseven(i) ? 2 : 1) + for attribute in (:fillrange, :ribbon) + @test plot(data4; NamedTuple{tuple(attribute)}(0)...)[1][i][attribute] == 0 + @test plot(data4; NamedTuple{tuple(attribute)}(Ref([1, 2]))...)[1][i][attribute] == [1.0, 2.0] + @test plot(data4; NamedTuple{tuple(attribute)}(Ref([1 2]))...)[1][i][attribute] == (iseven(i) ? 2 : 1) + @test plot(data4; NamedTuple{tuple(attribute)}(Ref(mat))...)[1][i][attribute] == [2(i-1)+1, 2i] + end end end