Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improvements to PlotSpecs and the SpecAPI #3628

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/specapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would people think if, knowing the default_theme of P()::Plot here, we populate the missing attributes with their default values as Observables in p::PlotList, so that users can edit them post-facto and have them pass through like normal Observables?

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)
Expand All @@ -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
Expand Down
Loading