From 1ab681f509fd5e4e34a223b75d0948f9f22c002c Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 9 Jul 2020 12:23:27 +0200 Subject: [PATCH] fix ribbons (#2853) * fix ribbons * fix tests --- src/backends/pgfplotsx.jl | 30 +++++++++++++----------------- test/test_pgfplotsx.jl | 10 +++------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 226e3327..84161ee9 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -344,9 +344,8 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) end # add fillrange if sf !== nothing && - !isfilledcontour(series) && - series[:ribbon] === nothing - if sf isa Number || sf isa AVec + !isfilledcontour(series) + if sf isa Number || sf isa AVec pgfx_fillrange_series!( axis, series, @@ -355,6 +354,17 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) _cycle(sf, rng), rng, ) + elseif sf isa Tuple + for sfi in sf + pgfx_fillrange_series!( + axis, + series, + series_func, + i, + _cycle(sfi, rng), + rng, + ) + end end if i == 1 && sp[:legend] != :none && pgfx_should_add_to_legend(series) @@ -384,17 +394,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) ), ) end - # add ribbons? - ribbon = series[:ribbon] - if ribbon !== nothing - pgfx_add_ribbons!( - axis, - series, - segment_plot, - series_func, - series_index, - ) - end # add to legend? if sp[:legend] != :none leg_entry = if opt[:label] isa AVec @@ -412,9 +411,6 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) push!(axis.contents[end].options, "forget plot" => nothing) else leg_opt = PGFPlotsX.Options() - if ribbon !== nothing - pgfx_filllegend!(axis.contents[end - 3].options, opt) - end legend = PGFPlotsX.LegendEntry(leg_opt, leg_entry, false) push!(axis, legend) end diff --git a/test/test_pgfplotsx.jl b/test/test_pgfplotsx.jl index 302d4fb2..9345018a 100644 --- a/test/test_pgfplotsx.jl +++ b/test/test_pgfplotsx.jl @@ -314,16 +314,12 @@ end Plots._update_plot_object(ribbon_plot) axis = Plots.pgfx_axes(ribbon_plot.o)[1] plots = filter(x -> x isa PGFPlotsX.Plot, axis.contents) - @test length(plots) == 4 - @test !haskey(plots[1].options.dict, "fill") - @test !haskey(plots[2].options.dict, "fill") + @test length(plots) == 3 + @test haskey(plots[1].options.dict, "fill") + @test haskey(plots[2].options.dict, "fill") @test !haskey(plots[3].options.dict, "fill") - @test haskey(plots[4].options.dict, "fill") @test ribbon_plot.o !== nothing @test ribbon_plot.o.the_plot !== nothing - # mktempdir() do path - # @test_nowarn savefig(ribbon_plot, path*"ribbon.svg") - # end end # testset end # testset