I am drawing an interactive plot with GLMakie that includes sliders. Is it possible to make a button to save the figure, preferably with the sliders or better with/without it?
I can draw the button, but is there a simple function to capture the plot? Thank you
Yes it’s possible, what is the “plot” in your case? An Axis
or and LScene
or something else? For LScene
you could save colorbuffer(lscene.scene)
. For Axis
there’s colorbuffer(ax)
I think, that was buggy recently but might be fixed already.
Hello, it would be the whole fig = Figure(size = (1920, 1080))
. I would need to save the current figure drawn with the current settings. The best would be to save the figure alone (without sliders) and the settings in a file…
You seem to be saying two different things, “the whole fig” and “the figure alone without sliders”. Maybe example code would be best.
Here is my save button.
The showblock! function was provided to me on this forum:
function showblock!(block,state::Bool)
# found on Discourse forum.
function _hide!(block::Scene)
foreach(_hide!, block.plots)
foreach(_hide!, block.children)
end
_hide!(plot) = plot.visible = state
_hide!(block.blockscene)
end
on(topbutton[12].clicks) do click12 # save fig
if (now() - change[]) > Millisecond(500)
showblock!.(topbutton,false)
showblock!(menu1,false)
showblock!(menu1lab,false)
showblock!(menu2,false)
showblock!.(toggle,false)
showblock!.(toglabs,false)
save(figsavefolder*"/"*string(forexampledateortime)*".png",fig)
showblock!.(topbutton,true)
showblock!(menu1,true)
showblock!(menu1lab,true)
showblock!(menu2,true)
showblock!.(toggle,true)
showblock!.(toglabs,true)
change[] = now()
end
end
I included a mechanism that stops the button being pressed more than once per half second. I seem to get double triggers a lot otherwise.
Thank you. This is very thorough. If I run save(fig), I can simply save the whole picture with sliders.