# Large size of plot files generated using Plots.jl with GR backend

**URL:** https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261
**Category:** General Usage
**Tags:** plotting
**Created:** [November 7, 2018, 3:13pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261 "2018-11-07T15:13:25Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Tbl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbl/32/5984_2.png) [@Tbl](https://discourse.julialang.org/u/Tbl)
#### Post date: [November 7, 2018, 3:13pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/1 "2018-11-07T15:13:25Z")

</div>

The sizes of the plot files generated by GR are sometimes ridiculously large. Changing dpi does not help significantly. After some experimenting, it seems it is caused by LaTeX text. For example

> gr()  
> xi = 0:0.1:10  
> plot(xi,sin.(xi), xlabel=L"\sin\cos x\_y", ylabel=L"\frac{42}{42}“, label=L”\mathcal N")  
> savefig(“fig.pdf”)

generates plot which has 1.94 MB. I have checked this behaviour on 2 computers. It is also the same when not using LaTeXStrings, like

> ylabel = “$\sin $”

Does anyone know how to fix this problem?

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [November 7, 2018, 3:33pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/2 "2018-11-07T15:33:55Z")

</div>

LaTeX text is internally created using `dvipng` - so, this is the normal behaviour, as all math text is displayed using images.

---

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [November 7, 2018, 3:36pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/3 "2018-11-07T15:36:39Z")

</div>

> Does anyone know how to fix this problem?

not really, but `pyplot()` produces small files. Need to replace `\mathcal`, though.

---

<div class="post-metadata">

### Author: ![Tbl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbl/32/5984_2.png) [@Tbl](https://discourse.julialang.org/u/Tbl)
#### Post date: [November 7, 2018, 4:52pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/4 "2018-11-07T16:52:07Z")

</div>

This is a reasonable advice, unfortunately after upgrading to Julia 1.0 I cannot make pyplot() working. Frankly, I would rather switch my project to Python instead of wasting time making Python work in Julia.

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [November 7, 2018, 6:42pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/5 "2018-11-07T18:42:31Z")

</div>

> [@Tbl](#):
>
> Frankly, I would rather switch my project to Python instead of wasting time making Python work in Julia.

Maybe a hybrid: write results to the file and plot them in Python.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [November 7, 2018, 7:57pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/6 "2018-11-07T19:57:28Z")

</div>

> [@Tbl](#):
>
> I would rather switch my project to Python instead of wasting time making Python work in Julia.

Yes, I mean, who would even consider using a programming language in which one of the plotting packages causes saved png files to be large? :troll:

---

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [November 7, 2018, 8:55pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/7 "2018-11-07T20:55:13Z")

</div>

If you really want graphics with LaTeX, then this is perhaps a nice idea:

[https://kristofferc.github.io/PGFPlotsX.jl/latest/examples/gallery.html#manual\_gallery-1](https://kristofferc.github.io/PGFPlotsX.jl/latest/examples/gallery.html#manual_gallery-1)

---

<div class="post-metadata">

### Author: ![Tbl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbl/32/5984_2.png) [@Tbl](https://discourse.julialang.org/u/Tbl)
#### Post date: [November 7, 2018, 9:48pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/8 "2018-11-07T21:48:27Z")

</div>

Thank you, I know it, but I haven’t checked it in detail, maybe I should. The devil is in the details, I often need to tweak plots a lot, so the control options are crucial. I have hoped that Plots.jl could be easy to use and strong enough, but I am becoming increasingly doubtful. I tried doing what I can in Plots.jl and the rest in PyPlot.jl, but some options from matplotlib did not work. Then it stopped working althogether. For matplotlib at least I know it is (mostly) working and you really can change a lot…

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [November 7, 2018, 11:31pm UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/9 "2018-11-07T23:31:32Z")

</div>

If you really need all the control options, just use PyPlot (without Plots). That should give essentially the same experience as you have with matplotlib in Python. Plots is not as customisable.

---

<div class="post-metadata">

### Author: ![Tbl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbl/32/5984_2.png) [@Tbl](https://discourse.julialang.org/u/Tbl)
#### Post date: [November 8, 2018, 8:46am UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/10 "2018-11-08T08:46:12Z")

</div>

I have tried. Basic stuff did work, but using some more advanced options resulted in errors.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 8, 2018, 9:12am UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261/11 "2018-11-08T09:12:11Z")

</div>

> [@Tbl](#):
>
> using some more advanced options resulted in errors

If you want to get help, your best route is probably creating an MWE and reporting said errors.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
