From 92bc1f3e95caa60838639683dfb1c648906d045f Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Sat, 3 Jul 2021 16:03:20 +0200 Subject: [PATCH] fix dispatches --- src/plot.jl | 7 ++++--- test/runtests.jl | 1 + test/test_pipeline.jl | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 test/test_pipeline.jl diff --git a/src/plot.jl b/src/plot.jl index fb802774..9ea8439f 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -90,9 +90,9 @@ function plot(args...; kw...) end # build a new plot from existing plots -# note: we split into plt1 and plts_tail so we can dispatch correctly -plot(plt1::Plot, plts_tail::Plot...; kw...) = plot!(deepcopy(plt1), deepcopy.(plts_tail)...; kw...) -function plot!(plt1::Plot, plts_tail::Plot...; kw...) +# note: we split into plt1, plt2 and plts_tail so we can dispatch correctly +plot(plt1::Plot, plt2::Plot, plts_tail::Plot...; kw...) = plot!(deepcopy(plt1), deepcopy(plt2), deepcopy.(plts_tail)...; kw...) +function plot!(plt1::Plot, plt2::Plot, plts_tail::Plot...; kw...) @nospecialize plotattributes = KW(kw) RecipesPipeline.preprocess_attributes!(plotattributes) @@ -186,6 +186,7 @@ function plot!(args...; kw...) end # this adds to a specific plot... most plot commands will flow through here +plot(plt::Plot, args...; kw...) = plot!(deepcopy(plt), args...; kw...) function plot!(plt::Plot, args...; kw...) @nospecialize plotattributes = KW(kw) diff --git a/test/runtests.jl b/test/runtests.jl index 997e1258..5221f6b1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,6 +30,7 @@ end end # testset include("test_defaults.jl") +include("test_pipeline.jl") include("test_axes.jl") include("test_axis_letter.jl") include("test_components.jl") diff --git a/test/test_pipeline.jl b/test/test_pipeline.jl new file mode 100644 index 00000000..2c81dfeb --- /dev/null +++ b/test/test_pipeline.jl @@ -0,0 +1,10 @@ +using Plots, Test + +@testset "plot" begin + pl = plot(1:5) + pl2 = plot(pl, tex_output_standalone = true) + @test pl[:tex_output_standalone] == false + @test pl2[:tex_output_standalone] == true + plot!(pl, tex_output_standalone = true) + @test pl[:tex_output_standalone] == true +end