diff --git a/src/args.jl b/src/args.jl index 5c39de57..447de838 100644 --- a/src/args.jl +++ b/src/args.jl @@ -281,6 +281,7 @@ const _series_defaults = KW( # one logical series to be broken up (path and markers, for example) :hover => nothing, # text to display when hovering over the data points :stride => (1,1), # array stride for wireframe/surface, the first element is the row stride and the second is the column stride. + :extra_kwargs => KW() ) @@ -304,8 +305,8 @@ const _plot_defaults = KW( :dpi => DPI, # dots per inch for images, etc :thickness_scaling => 1, :display_type => :auto, - :extra_kwargs => KW(), - :warn_on_unsupported => true, + :extra_plot_kwargs => KW(), + :extra_kwargs => :series # directs collection of extra_kwargs ) @@ -354,6 +355,7 @@ const _subplot_defaults = KW( :colorbar_title => "", :framestyle => :axes, :camera => (30,30), + :extra_kwargs => KW() ) const _axis_defaults = KW( diff --git a/src/pipeline.jl b/src/pipeline.jl index 56a5f054..7f655674 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -341,7 +341,21 @@ function _expand_subplot_extrema(sp::Subplot, plotattributes::AKW, st::Symbol) end function _add_the_series(plt, sp, plotattributes) - plt[:extra_kwargs][:series] = warn_on_unsupported_args(plt.backend, plotattributes) + extra_kwargs = warn_on_unsupported_args(plt.backend, plotattributes) + @show plt[:extra_kwargs] + if (kw = plt[:extra_kwargs]) isa AbstractDict + merge!(plt[:extra_plot_kwargs], get(kw,:plot,KW())) + merge!(sp[:extra_kwargs], get(kw,:subplot, KW())) + merge!(plotattributes[:extra_kwargs], get(kw,:series,KW())) + elseif plt[:extra_kwargs] == :plot + merge!(plt[:extra_plot_kwargs], extra_kwargs) + elseif plt[:extra_kwargs] == :subplot + merge!(sp[:extra_kwargs], extra_kwargs) + elseif plt[:extra_kwargs] == :series + merge!(plotattributes[:extra_kwargs], extra_kwargs) + else + ArgumentError("Unsupported type for extra keyword arguments") + end warn_on_unsupported(plt.backend, plotattributes) series = Series(plotattributes) push!(plt.series_list, series) diff --git a/test/test_pgfplotsx.jl b/test/test_pgfplotsx.jl index 99ec4dba..89b2f84a 100644 --- a/test/test_pgfplotsx.jl +++ b/test/test_pgfplotsx.jl @@ -329,6 +329,13 @@ end # testset @testset "Extra kwargs" begin pl = plot(1:5, test = "me") - @test pl.attr[:extra_kwargs][:series][:test] == "me" + @test pl[1][1].plotattributes[:extra_kwargs][:test] == "me" + pl = plot(1:5, test = "me", extra_kwargs = :subplot) + @test pl[1].attr[:extra_kwargs][:test] == "me" + pl = plot(1:5, test = "me", extra_kwargs = :plot) + @test pl.attr[:extra_plot_kwargs][:test] == "me" + pl = plot(1:5, extra_kwargs = Dict(:plot => Dict(:test => "me"), :series => Dict(:and => "me too"))) + @test pl.attr[:extra_plot_kwargs][:test] == "me" + @test pl[1][1].plotattributes[:extra_kwargs][:and] == "me too" end # testset