# Savefig not defined using, only able to save as .svg file

**URL:** <https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129>\
**Category:** New to Julia\
**Created:** [October 2, 2022, 5:07pm UTC](https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129 "2022-10-02T17:07:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Beez](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Max\_Beez](https://discourse.julialang.org/u/Max_Beez)\
**Post date:** [October 2, 2022, 5:07pm UTC](https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129/1 "2022-10-02T17:07:52Z")

</div>

I am trying to save plots of simulations I am running. Here is the code:

> p1 = plot(sim, layout=(1,3), linealpha=0.9,color=[:blue :red :green], size = [1200,400])  
> p2 = plot!(sol, layout=(1,3), linealpha=1,lw=3.0,color=[:black :black :black],title=“”, size = [1200,400])  
> plot(p1)  
> savefig(p1, “test.png”)

And I get the following error:

> ERROR: UndefVarError: savefig not defined  
> Stacktrace:  
> [1] \_show(io::IOStream, #unused#::MIME{Symbol(“image/png”)}, plt::Plots.Plot{Plots.PlotlyBackend})  
> @ Plots ~/.julia/packages/Plots/1KWPG/src/backends/plotlybase.jl:21  
> [2] show  
> @ ~/.julia/packages/Plots/1KWPG/src/output.jl:212 [inlined]  
> [3] #269  
> @ ~/.julia/packages/Plots/1KWPG/src/output.jl:6 [inlined]  
> [4] open(::Plots.var"#269#270"{Plots.Plot{Plots.PlotlyBackend}}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
> @ Base ./io.jl:330  
> [5] open  
> @ ./io.jl:328 [inlined]  
> [6] png(plt::Plots.Plot{Plots.PlotlyBackend}, fn::String)  
> @ Plots ~/.julia/packages/Plots/1KWPG/src/output.jl:5  
> [7] savefig(plt::Plots.Plot{Plots.PlotlyBackend}, fn::String)  
> @ Plots ~/.julia/packages/Plots/1KWPG/src/output.jl:121  
> [8] top-level scope  
> @ ~/Param/parallel.jl:83

Now if I delete

> savefig(p1, “test.png”)

then I am able to get a plot and then can save but only as a .svg file.

I am using the PlotlyBase backend.

EDIT: now I can get it to save but it is empty when i try to open it. Moreover, why when I save it does it not also open the plot in the plots pane.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [October 2, 2022, 6:46pm UTC](https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129/2 "2022-10-02T18:46:36Z")

</div>

```julia
]status Plots

```

?

---

<div class="post-metadata">

**Author:** ![Max\_Beez](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Max\_Beez](https://discourse.julialang.org/u/Max_Beez)\
**Post date:** [October 2, 2022, 7:12pm UTC](https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129/3 "2022-10-02T19:12:32Z")

</div>

```
  Status `~/.julia/environments/v1.7/Project.toml`
  [91a5bcdd] Plots v1.29.0

```

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [October 2, 2022, 7:23pm UTC](https://discourse.julialang.org/t/savefig-not-defined-using-only-able-to-save-as-svg-file/88129/4 "2022-10-02T19:23:35Z")

</div>

You are probably using PlotlyBase 0.8, you need to use PlotlyBase 0.7 (there should have been a warning)

Should also be fixed on newer versions of Plots
