conserve extra_kwargs (#2885)
* conserve extra_kwargs * Update test_pgfplotsx.jl * remove wraptuples * Update test_pgfplotsx.jl * Update test_pgfplotsx.jl * Update test_pgfplotsx.jl * Update test_pgfplotsx.jl * Revert "remove wraptuples" This reverts commit 6d66d69692ad1ffb72a99ed4777658d14ad749f1. * Auto stash before revert of "remove wraptuples"
This commit is contained in:
parent
5673ced5d7
commit
345bceb526
@ -83,17 +83,17 @@ function Base.push!(pgfx_plot::PGFPlotsXPlot, item)
|
||||
push!(pgfx_plot.the_plot, item)
|
||||
end
|
||||
|
||||
function pgfx_split_extra_opts(extra)
|
||||
return (get(extra, :add, nothing), filter( x-> first(x) != :add, extra))
|
||||
end
|
||||
function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
if !pgfx_plot.is_created || pgfx_plot.was_shown
|
||||
pgfx_sanitize_plot!(plt)
|
||||
# extract extra kwargs
|
||||
extra_plot_opt = plt[:extra_plot_kwargs]
|
||||
extra_plot = nothing
|
||||
if haskey(extra_plot_opt, :add)
|
||||
extra_plot = wraptuple(pop!(extra_plot_opt,:add))
|
||||
end
|
||||
extra_plot, extra_plot_opt = pgfx_split_extra_opts(plt[:extra_plot_kwargs])
|
||||
the_plot = PGFPlotsX.TikzPicture(PGFPlotsX.Options(extra_plot_opt...))
|
||||
if extra_plot !== nothing
|
||||
extra_plot = wraptuple(extra_plot)
|
||||
push!(the_plot, extra_plot...)
|
||||
end
|
||||
bgc = plt.attr[:background_color_outside] == :match ?
|
||||
@ -249,13 +249,10 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
else
|
||||
PGFPlotsX.Axis
|
||||
end
|
||||
extra_sp_opt = sp[:extra_kwargs]
|
||||
extra_sp = nothing
|
||||
if haskey(extra_sp_opt, :add)
|
||||
extra_sp = wraptuple(pop!(extra_sp_opt,:add))
|
||||
end
|
||||
extra_sp, extra_sp_opt = pgfx_split_extra_opts(sp[:extra_kwargs])
|
||||
axis = axisf(merge(axis_opt, PGFPlotsX.Options(extra_sp_opt...)))
|
||||
if extra_sp !== nothing
|
||||
extra_sp = wraptuple(extra_sp)
|
||||
push!(axis, extra_sp...)
|
||||
end
|
||||
if sp[:legendtitle] !== nothing
|
||||
@ -279,11 +276,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
"color" => single_color(opt[:linecolor]),
|
||||
"name path" => string(series_id),
|
||||
)
|
||||
extra_series_opt = series[:extra_kwargs]
|
||||
extra_series = nothing
|
||||
if haskey(extra_series_opt, :add)
|
||||
extra_series = wraptuple(pop!(extra_series_opt,:add))
|
||||
end
|
||||
extra_series, extra_series_opt = pgfx_split_extra_opts(series[:extra_kwargs])
|
||||
series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...))
|
||||
if RecipesPipeline.is3d(series) || st in (:heatmap, :contour)
|
||||
series_func = PGFPlotsX.Plot3
|
||||
@ -376,6 +369,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
segment_plot =
|
||||
series_func(merge(series_opt, segment_opt), coordinates)
|
||||
if extra_series !== nothing
|
||||
extra_series = wraptuple(extra_series)
|
||||
push!(segment_plot, extra_series...)
|
||||
end
|
||||
push!(axis, segment_plot)
|
||||
|
||||
@ -341,4 +341,14 @@ end # testset
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test !haskey(axes[1].options.dict, "axis line shift")
|
||||
@test haskey(axes[2].options.dict, "axis line shift")
|
||||
pl = plot(x->x, -1:1; add = raw"\node at (0,0.5) {\huge hi};", extra_kwargs = :subplot)
|
||||
@test pl[1][:extra_kwargs] == Dict(:add => raw"\node at (0,0.5) {\huge hi};")
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test filter(x->x isa String, axes[1].contents)[1] == raw"\node at (0,0.5) {\huge hi};"
|
||||
plot!(pl)
|
||||
@test pl[1][:extra_kwargs] == Dict(:add => raw"\node at (0,0.5) {\huge hi};")
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test filter(x->x isa String, axes[1].contents)[1] == raw"\node at (0,0.5) {\huge hi};"
|
||||
end # testset
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user