In Plots.jl, I can make a plot and then use it either as a stand-alone figure or as a subplot:
myplot(n) = plot(1 : n; xlabel = "x")
f1 = myplot(10);
f2 = myplot(20);
fig = plot(f1, f2);
Can I do something similar in Makie.jl?
I can, of course, define
fig = Figure();
ax = fig[1,1] = Axis(fig; xlabel = "x");
function myplot!(ax, n)
But I am hoping for a less verbose solution where I don’t have to define two functions for each type of plot that I want to generate. How can I do this?
Is it a plot like a combination of basic plot types? If so, use the recipe macro to define a new recipe which will have all the axis and figure generating convenience methods. Or is this supposed to be something that generates multiple subplots already?
They are not basic plots. To give context, I simulate a model and report statistics that are grouped in certain ways.
So I have a function that plots a statistic grouped by, say, (:a, :b). There are customizations that are specific to (:a, :b).
This is called in various places and sometimes combined into subplots and sometimes not.
What I often do currently, because we don’t have subplot level recipes yet, is to make a function that receives either a Figure or a FigurePosition. If there’s no input argument, a new figure is created. This then works for both the single figure and subplot case.
function myplot(f = Figure())
Thank you - this is helpful. I have to play around with this for a bit to really understand the syntax, but I will close this for now.