I have a function that creates a Makie plot. I want it to display that plot by default, but to also return other information, let’s say fig and ax, so it can be called as fig, ax = myplot(x). I’m using show == true && display(fig) in the function so as to have the option to avoid displaying the figure.
So far everything is great so far, but the problem is how to make it easy to show the figure in Pluto as well. I know that myplot(x)[1] will do the trick, but would it be possible to show it with directly with myplot(x) or to find a more elegant solution?
Makie does this same thing with the FigureAxisPlot type, it’s a single return value so display can work automatically once show is overloaded, but it also has an iterate overload so the fig, ax, p = ... thing works.
Thanks. I’m just trying to have something that easily works for students without a computational background. Maybe it helps to show the end of the function:
p = meshscatter!(ax,X[framenum,:],Y[framenum,:],Z[framenum,:],markersize=msize,color=mcolor,colormap=mcolormap,clip_planes=Plane3f[])
…
show == true && display(fig)
return fig, ax, p, X, Y, Z, txt, conn, pl