# Save main scene (with axis ticks and spines) to file without closing current window

**URL:** <https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684>\
**Category:** General Usage\
**Tags:** visualization, makie\
**Created:** [July 15, 2021, 11:01am UTC](https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684 "2021-07-15T11:01:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [July 15, 2021, 11:01am UTC](https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684/1 "2021-07-15T11:01:36Z")

</div>

The following works more or less. But, it will be better to actually save the scene with all the spines and ticks values, plus the window is closing when I hit the button save. Any suggestions?

```julia
using GLMakie
with_theme(theme_minimal()) do 
    fig = Figure()
    menu = Menu(fig, options = ["save to file"])
    menu2 = Menu(fig, options = ["Spectral_11", "viridis", "heat"])    
    ax = Axis(fig[1, 1])
    toggles = [Toggle(fig, active = active) for active in [true, false]]
    labels = [Label(fig, lift(x -> x ? "$l visible" : "$l invisible", t.active))
        for (t, l) in zip(toggles, ["sine", "cosine"])]

    fig[1, 2] = grid!(hcat(toggles, labels), tellheight = false)

    line1 = lines!(0..10, sin, color = :blue, visible = false)
    line2 = lines!(0..10, cos, color = :red)
    pltobj = heatmap!(1:3, 0:0.1:0.5, rand(3,5))
    fig[1, 0] = vgrid!(
        Label(fig, "Save ?", width = nothing), menu, 
        Label(fig, "colormap", width = nothing), menu2; tellheight = false, width = 200)
    on(menu.selection) do s
        save("testFile.png", ax.scene, resolution = (1900,800)) # not good, axis are gone 
    end
    on(menu2.selection) do s
        pltobj.colormap = s
    end
    connect!(line1.visible, toggles[1].active)
    connect!(line2.visible, toggles[2].active)
    fig
end

```

---

<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:** [July 15, 2021, 12:21pm UTC](https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684/2 "2021-07-15T12:21:30Z")

</div>

The internal axis scene just doesn’t contain the axis spines etc, that’s why they’re missing if you save it like that. I’m not sure that what you wish for can work currently, as you can’t transplant an existing axis into a second figure either.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 15, 2021, 12:34pm UTC](https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684/3 "2021-07-15T12:34:58Z")

</div>

Is there a way to save without closing the plot window?  
This occurs in Win10 for `save` arguments: `ax.scene` or `fig`.

---

<div class="post-metadata">

**Author:** ![kaltsoplyn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaltsoplyn/32/46634_2.png) [@kaltsoplyn](https://discourse.julialang.org/u/kaltsoplyn)\
**Post date:** [February 8, 2023, 5:39pm UTC](https://discourse.julialang.org/t/save-main-scene-with-axis-ticks-and-spines-to-file-without-closing-current-window/64684/4 "2023-02-08T17:39:17Z")

</div>

**+1** about the window closing when the save button is clicked.

**System:** Windows 11, **GLMakie 0.8.2** (with Makie **0.19.2** and MakieCore **0.6.2** installed as deps). Sometimes there’s an error about the inability to keep the window content current (or something along these lines), but mostly it just fails silently.
