# Julia plot not saved properly

**URL:** https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162
**Category:** General Usage
**Tags:** plotting
**Created:** [June 11, 2019, 6:14pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162 "2019-06-11T18:14:18Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![surajp92](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@surajp92](https://discourse.julialang.org/u/surajp92)
#### Post date: [June 11, 2019, 6:14pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/1 "2019-06-11T18:14:18Z")

</div>

I am using Plots to create the XY plot and then saving it in the pdf format. But the text in the ylabel is not saved properly. The power of the 10 is not saved and the number appears like 1.0X10 instead of 1.0X10^-8. Below is the part of the code I am using for plotting. x and y are arrays of the same size.

```julia
color=[:red :blue]

p = plot(x,y,lw = 3,
         ylabel = "L2 Norm", yscale = :log10,
         xlabel="Iteration count", #xlims=(0,maximum(iter_hist)+1),
         grid=(:none),
         label=["rms" "rms/rms\$_0\$"], color=color)
         
savefig(p,"gs_residual.png")

```

Below is the saved .png file. As you can see, the numbers on the x-axis are not printed correctly and the exponent is missing. Even if I save the figure in .pdf format I get the same results.

![gs_residual](https://global.discourse-cdn.com/julialang/original/3X/e/9/e9075b377be54bce79344dc5d89e402792c6c269.png)

Thank you. Regards,

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [June 12, 2019, 12:24am UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/2 "2019-06-12T00:24:04Z")

</div>

Hi @surajp92, welcome to the forums! Could you please post the code (or ideally a minimum working example) that reproduces your problem? If you provide code that people can run that reproduces your problem, and maybe post a screenshot of the plot that doesn’t look the way you intend, it will enable people to help you more easily. At the moment, you haven’t really provide enough detail to diagnose the issue.

Please also [take a look at this post](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) for information on how to format the code in your post and other useful information

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [June 15, 2019, 3:23pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/3 "2019-06-15T15:23:22Z")

</div>

Thanks for the edit - much clearer! I haven’t seen that before, and it’s especially weird that it looks fine on the y axis. Are you using the default GR back end?

---

<div class="post-metadata">

### Author: ![surajp92](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@surajp92](https://discourse.julialang.org/u/surajp92)
#### Post date: [June 18, 2019, 10:08pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/4 "2019-06-18T22:08:37Z")

</div>

I am using Plot package ([Home · Plots](http://docs.juliaplots.org/latest/)). Yeah, on Y-axis we get correct number. But for some reason, the exponent is missing in x-axis numbers. Is it different than the GR package?  
Thank you.

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [June 19, 2019, 10:32am UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/5 "2019-06-19T10:32:59Z")

</div>

Plots.jl doesn’t actually do any drawing of plots - its a common API to a number of [different backends](https://docs.juliaplots.org/latest/backends/). GR is the default though, so if you didn’t intentionally change it, that’s what you’re using.

I don’t have a good explanation - it might be worth trying to do the same thing with GR.jl, and then open an issue there if you see the same behavior, or on Plots.jl if you don’t.

---

<div class="post-metadata">

### Author: ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)
#### Post date: [June 19, 2019, 1:29pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/6 "2019-06-19T13:29:33Z")

</div>

Which backend are you using? Try:

```julia
plotly()
color=[:red :blue]

p = plot(x,y,lw = 3,
         ylabel = "L2 Norm", yscale = :log10,
         xlabel="Iteration count", #xlims=(0,maximum(iter_hist)+1),
         grid=(:none),
         label=["rms" "rms/rms\$_0\$"], color=color)
         
savefig(p,"gs_residual.png")

```

and see what happens? It could be that your backend is not rendering the Unicode characters correctly.

---

<div class="post-metadata">

### Author: ![surajp92](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@surajp92](https://discourse.julialang.org/u/surajp92)
#### Post date: [June 19, 2019, 8:50pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/7 "2019-06-19T20:50:37Z")

</div>

using plotly() did not helped. I am using PyPlot which offers matplotlib interface for Julia.  
Thank you all for your help.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [June 19, 2019, 9:19pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/8 "2019-06-19T21:19:59Z")

</div>

If you provide an example of how you generate `x` and `y`, it will be easier for others to test and compare what it looks like on other computers. On my computer (Windows 10, Julia v. 1.1.1), it looks fine:

```julia
julia> x = range(pi,3pi,length=100);
julia> y = hcat(2 .+ sin.(x), 2 .+ cos.(x));
julia> plot(x,y,lc=[:red :blue], xscale=:log10, yscale=:log10,label=["2+sin(x)" "2+cos(x)"])

```

leading to:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/1/318403a8b9177a4c04163a03dd47e70d43d777fa.png)

My data are surely different from yours,

---

<div class="post-metadata">

### Author: ![surajp92](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@surajp92](https://discourse.julialang.org/u/surajp92)
#### Post date: [June 19, 2019, 9:38pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162/9 "2019-06-19T21:38:21Z")

</div>

I think I found the problem. I was running the code directly in Atom ide. If I run it from the terminal then I get correct xticks values with the exponent. Also, I am setting the global font in the beginning of my code

```julia
font = Plots.font("Times New Roman", 18)

```

Thank you all for your help.
