From f085640d374cd053def399b79e92e89609a34543 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 13 Feb 2024 11:46:22 -0500 Subject: [PATCH] Forward PlotSpec attributes to plots at creation time This doesn't allow post facto editing, but e.g. `plot(diffeq_solution; linewidth = 0.1)` will at least work. --- src/specapi.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/specapi.jl b/src/specapi.jl index fe6eec19b61..e812e798401 100644 --- a/src/specapi.jl +++ b/src/specapi.jl @@ -401,6 +401,13 @@ function to_plot_object(ps::PlotSpec) return P((ps.args...,), copy(ps.kwargs)) end +function to_plot_object(ps::PlotSpec, p::PlotList) + P = plottype(ps) + return P((ps.args...,), merge(Dict(p.attributes), copy(ps.kwargs))) +end + +to_plot_object(ps::PlotSpec, ::Nothing) = to_plot_object(ps) + function find_reusable_plot(plotspec::PlotSpec, reusable_plots::IdDict{PlotSpec,Plot}) for (spec, plot) in reusable_plots if compare_specs(spec, plotspec) @@ -424,7 +431,7 @@ function diff_plotlist!(scene::Scene, plotspecs::Vector{PlotSpec}, obs_to_notify if isnothing(reused_plot) @debug("Creating new plot for spec") # Create new plot, store it into our `cached_plots` dictionary - plot = plot!(scene, to_plot_object(plotspec)) + plot = plot!(scene, to_plot_object(plotspec, plotlist)) if !isnothing(plotlist) push!(plotlist.plots, plot) end