function foo(fig = Makie.Figure())
axes = [Makie.Axis(fig[i,j]) for j in 1:3, i in 1:2]
for (i, ax) in enumerate(axes)
Makie.scatter!(ax, randn(10))
ax.title = "Plot number $i"
end
fig
end
I’d like users to be able to edit the plot afterwards (like adding or remove titles). Is there a recommended way to do this?
I wasn’t sure how to recover axes from the return argument fig. I thought maybe I should return a Makie.FigureAxisPlot instead so that there is a way to access the axis, but I wasn’t sure how to specify the plot field.
No recommended way, you can return the axes in a tuple with the Figure if they’re important, otherwise you could theoretically still get at them via the content function for example.
Thanks for the tip on content. However, fig.content is a vector instead of a matrix, and I’d like to pass the latter to users if possible since the layout is more intuitive.
If I return fig, axes in a tuple, the plot doesn’t pop up. I’d like to be able to call foo() to have the plot appear, but also return a configurable plot object. That’s why I was thinking of returning FigureAxisPlot - it returns axis information but also makes the plot pop up. However, I’m not sure what to provide for the plot field here.
using GLMakie
function foo(fig = Makie.Figure())
axes = [Makie.Axis(fig[i,j]) for j in 1:3, i in 1:2]
for (i, ax) in enumerate(axes)
Makie.scatter!(ax, randn(10))
ax.title = "Plot number $i"
end
display(fig)
fig, axes
end
fig, axesv = foo()
axesv[1].title = "Hello No.1 !"
axesv[5].title = "Hello No.5 !"
Yes, but it then requires typing fig to actually display the plot. I’d like to have foo() both display the figure, and also return axis information.
What Makie command does typing “fig” actually call to show the figure? I think I could wrap fig and axes in a custom type and overload the “show figure” command.