change to dict

This commit is contained in:
Simon Christ 2020-04-27 20:36:23 +02:00
parent 1b393d13f1
commit 6bb5b7831f
3 changed files with 27 additions and 4 deletions

View File

@ -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(

View File

@ -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)

View File

@ -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