# Plots.jl with GR: exporting to PDF

**URL:** <https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461>\
**Category:** General Usage\
**Tags:** plotting, bug\
**Created:** [January 18, 2018, 7:00pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461 "2018-01-18T19:00:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 18, 2018, 7:00pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/1 "2018-01-18T19:00:08Z")

</div>

Exporting to PDF by savefig() cuts off part of the (vertical) axis label in the resulting PDF file.

Is there a way to increase the size of the resulting bounding box or at least to manipulate the relative distance of the labels from the axes?

Tnx!!  
MG

```julia

using Plots
using LaTeXStrings

gr(size=(400,400), legend= false)

x = 0:10
y = x.^2

plot(x,y)

xlabel!(L"x")
ylabel!(L"x^2")

savefig("mytestplot.pdf")

```

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 18, 2018, 7:25pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/2 "2018-01-18T19:25:27Z")

</div>

Seems like a bug with the margin computation and having LaTeX in the axis labels. If there is no issue already it’s probably worth opening one.

Normally you can play with the keyword `left_margin`, for example:

```julia
using Plots.Measures
plot(x, y, left_margin = 3mm)

```

but I’m afraid it won’t help you in this case as it controls the distance between axis label and axis (it would help if for example the problem was that the axis label overlaps with the tick labels).

---

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 19, 2018, 7:06pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/3 "2018-01-19T19:06:44Z")

</div>

> [@piever](#):
>
> left\_margin = 3mm

Did not work (I had forgotten to include “using Plots.Measures”)…  
I am temporarily solving this issue by

```julia
L".... x^2"

```

(or replacing the dots with a random letter)

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 19, 2018, 7:09pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/4 "2018-01-19T19:09:49Z")

</div>

Turned out to be a bug in GR (or at least there is a related bug in GR):

[https://github.com/jheinen/GR.jl/issues/92](https://github.com/jheinen/GR.jl/issues/92)

---

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 19, 2018, 7:13pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/5 "2018-01-19T19:13:41Z")

</div>

Thank you!  
I tried but searched for it in the wrong place (issues in “Plots.jl” and in “LaTeXStrings.jl”).

---

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 20, 2018, 12:26pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/6 "2018-01-20T12:26:44Z")

</div>

> [@piever](#):
>
> using Plots.Measures

May I ask you how …you spotted Plots.Measures ? I have almost 20 years of experience with Matlab (and with reading documentation) but it seems it is immensely difficult for me to browse Julia docs and, in particular, Julia’s plotting docs.

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 20, 2018, 12:59pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461/7 "2018-01-20T12:59:16Z")

</div>

I think there are two general issues: one (of which I’m guilty myself) is that Plots.jl contributors find many things very intuitive after a while and it’s difficult to tell what would be difficult/hard to find for a user; the other is that the community is much smaller than matlab’s, so googling is less helpful.

Other than browsing the docs, a very good tool is `plotattr`:

```julia
julia> plotattr()
Specify an attribute type to get a list of supported attributes. Options are Series, Subplot, Plot, Axis

julia> plotattr(:Subplot)
Defined Subplot attributes are:
annotations, aspect_ratio, background_color_inside, background_color_legend, background_color_subplot, bottom_margin, camera, clims, color_palette, colorbar, colorbar_title, fontfamily_subplot, foreground_color_legend, foreground_color_subplot, foreground_color_title, framestyle, left_margin, legend, legendfontcolor, legendfontfamily, legendfonthalign, legendfontrotation, legendfontsize, legendfontvalign, legendtitle, margin, projection, right_margin, subplot_index, title, title_location, titlefontcolor, titlefontfamily, titlefonthalign, titlefontrotation, titlefontsize, titlefontvalign, top_margin

julia> plotattr("margin")
margin {Measure (multiply by `mm`, `px`, etc)}

Base for individual margins... not directly used. Specifies the extra padding around subplots.
Subplot attribute, default: 1.0mm

```

Though it doesn’t specify that you need `using Measures` or `using Plots.Measures` to have access to `mm` or `cm`.

If you don’t find what you’re looking for in the docs, you can ask in the [gitter](https://gitter.im/tbreloff/Plots.jl) channel (or on slack) and you’ll probably receive an answer reasonably quickly. If you find that something relevant is missing from the docs, a PR to improve documentation is always very welcome (Plots.jl has an insane amount of features and even for its developers is hard to know all of them).
