# How to save the plot object in file instead of a jpg figure?

**URL:** <https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130>\
**Category:** General Usage\
**Tags:** question, visualization, makie\
**Created:** [January 18, 2023, 7:54am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130 "2023-01-18T07:54:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiz/32/211800_2.png) [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Post date:** [January 18, 2023, 7:54am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/1 "2023-01-18T07:54:23Z")

</div>

Hi,

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.

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

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

---

<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 18, 2023, 8:31am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/2 "2023-01-18T08:31:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tiZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiz/32/211800_2.png) [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Post date:** [January 18, 2023, 8:48am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/3 "2023-01-18T08:48:42Z")

</div>

Thank you for your patience in explaining. Have a good day.

---

<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:** [September 29, 2023, 7:01am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/4 "2023-09-29T07:01:55Z")

</div>

is this still the case?

---

<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:** [September 29, 2023, 7:30am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/5 "2023-09-29T07:30:38Z")

</div>

Yes, although there were some improvements in decoupling plot objects from scenes, which is a start

---

<div class="post-metadata">

**Author:** ![gcalderone](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gcalderone/32/1539_2.png) [@gcalderone](https://discourse.julialang.org/u/gcalderone)\
**Post date:** [September 29, 2023, 7:45am UTC](https://discourse.julialang.org/t/how-to-save-the-plot-object-in-file-instead-of-a-jpg-figure/93130/6 "2023-09-29T07:45:29Z")

</div>

In case [Gnuplot.jl](https://gcalderone.github.io/Gnuplot.jl/v1.4.1/) 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.

Further info [here](https://gcalderone.github.io/Gnuplot.jl/v1.4.1/basic/#Gnuplot-scripts).
