# How to save interactive plot with GLMakie

**URL:** <https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352>\
**Category:** Visualization\
**Created:** [January 2, 2025, 8:37am UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352 "2025-01-02T08:37:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 2, 2025, 8:37am UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/1 "2025-01-02T08:37:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 2, 2025, 8:43am UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/2 "2025-01-02T08:43:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 3, 2025, 9:40am UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/3 "2025-01-03T09:40:34Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 3, 2025, 9:49am UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/4 "2025-01-03T09:49:40Z")

</div>

You seem to be saying two different things, “the whole fig” and “the figure alone without sliders”. Maybe example code would be best.

---

<div class="post-metadata">

**Author:** ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Post date:** [January 3, 2025, 3:00pm UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/5 "2025-01-03T15:00:19Z")

</div>

Here is my save button.  
The showblock! function was provided to me on this forum:

```julia
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

```

```julia
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.

---

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 4, 2025, 3:15pm UTC](https://discourse.julialang.org/t/how-to-save-interactive-plot-with-glmakie/124352/6 "2025-01-04T15:15:10Z")

</div>

Thank you. This is very thorough. If I run save(fig), I can simply save the whole picture with sliders.
