I know that saving the code and data is the best way to reproduce scientific figures, but sometimes I also want to save the figure objects for future modify;like changing the colour scheme, adding text annotations or resizing. So it would be a great time saver if we could save the FigureAxisPlot object in a file.
I first tried to do this with JLD2.
x = y = [1,2,3]
G = scatter(x,y)
# save the figure
save("demo.jpg", G)
# and also the object G
# in the next time, I could load the G directly
JLD2.@save "G_for_demo.jld" G
But JLD2 complains that
JLD2.@save "G_for_demo.jld" G
ERROR: UndefVarError: ET not defined
So, any suggestions for saving G as a separate and loadable file?
Thank you in advance
You can’t currently reliably serialize Makie plots. They have a lot of internal anonymous functions that wouldn’t work when reloaded, and probably other objects like open font handles etc. There’s just not been any effort in that direction, yet, while it’s undoubtedly a good feature to have. Your best bet for reproducibility is having reproducible functions / scripts that create the plots, together with a reproducible environment.
In case Gnuplot.jl is an option, it provides the possibility to save all the data and plot settings in a script file, which can later be edited and executed independently from the Julia code to re-generate the plot.