I would like to organize some commonly used plots into functions. Eg
function makie_plot_posterior_check(figure, label, data, predicted;
scatter_color = alphacolor(colorant"black", 0.7),
diagonal_color = colorant"gray")
ax = Makie.Axis(figure; xlabel = "$(label) data", ylabel = "$(label) (posterior mean)")
Makie.ablines!(ax, [0], [1]; color = diagonal_color)
Makie.scatter!(ax, data, predicted; color = scatter_color)
figure
end
which I would then use as eg
f = Figure()
makie_plot_posterior_check(f[1,1], "male work hours", data.n1, predicted.n1)
save("output_path.svg", f)
The idea is that I may make a single plot of this kind, or a grid of them, etc, using this function.
But I find it tedious to have to pass in the figure/scene.
Is it possible/idiomatic to create an Axis
in Makie, then later on attach it to a Figure
(or scene)?
Or am I organizing my code the wrong way?