Is there a recommended way to save a figure in makie, akin to using savefig in Matlab as a “.fig” file?
No, because Makie figures contain lots of references to anonymous functions etc. due to observables and the compute graph and these don’t behave well under serialization. You could try if you can reload a figure serialized in one session with Julia’s default serialization, but I assume it won’t work well, or break at the slightest underlying change (Julia patch version, any package version change).
Okay, thanks. I’ll add that my ambitions plan is to have some interactive scatter plot where users can click dots and listen to music associated to them. I thought it could be a matter of just loading a figure but maybe I need to load preprocessed data instead.
You mean you wanted to do that without a julia session running? With a running julia, you could set up something like that, no need to save a figure.
You can either compile it as a program with GLMakie, or you may use export_static with WGLMakie, and program some js:
With e.g. claude code, it could be quite easy to come up with the correct js to play a sound etc ![]()
Thanks! Could be done with a running Julia. I guess I just need to split the pipeline and save some data instead of saving figs (which is what I’m used to do)
Where are you used to that? I guess something must load the saved figure one way or the other?
E.g. if its something like matlab, this means the user needs to have matlab installed to open the figure.
The same with Makie and Julia would be a package with an @main entry point, where you open the figure. The user then already has julia (must be 1.12+) and runs:
julia -e "using Pkg; Pkg.add("url-to-your-package")
julia -m YourPackage
Your package will just be:
module YourPackage
using GLMakie
function @main(ARGS)
fig = ...
wait(display(fig))
end
end
Sounds like experimental psychology which was completely matlab dominated when I did it
Thanks! I have seen @main before but didn’t try it; I’m used to running
include(“script.jl”); Mymodule.run()
or something like that. And that’s exactly the research field; the idea is to prepare something I could show later in a presentation. I think thatthis will do. The missing piece is how to play sound files when clicking on points or bars, but that challenge is a bit off topic I guess.
Something simple might be using ffplay from ffmpeg, which you can install through julia in the form of FFMPEG_jll so it’s easy to reproduce
Thanks! I used PortAudio instead, it worked like a charm!