# In Plots.jl, how does one control the space between ylabel and yaxis?

**URL:** <https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717>\
**Category:** Visualization\
**Created:** [September 5, 2017, 12:45am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717 "2017-09-05T00:45:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [September 5, 2017, 12:45am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/1 "2017-09-05T00:45:38Z")

</div>

I don’t seem to find any example or documentation about this.

---

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [September 5, 2017, 3:54am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/2 "2017-09-05T03:54:46Z")

</div>

I am answering my own question. I found that the option “left\_margin = 8mm” works.

---

<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:** [September 5, 2017, 6:22am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/3 "2017-09-05T06:22:21Z")

</div>

[https://juliaplots.github.io/attributes/](https://juliaplots.github.io/attributes/) and (in a julia session with Plots loaded) `plotattr(:Subplot)` (or `:Plot`, `:Axis`, `:Series`) are your friends.

---

<div class="post-metadata">

**Author:** ![Pavel\_Dytrych](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pavel_dytrych/32/51327_2.png) [@Pavel\_Dytrych](https://discourse.julialang.org/u/Pavel_Dytrych)\
**Post date:** [September 5, 2017, 6:10pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/4 "2017-09-05T18:10:06Z")

</div>

Thank you for this link - very helpful! 🙂

---

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [September 6, 2017, 12:49am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/5 "2017-09-06T00:49:22Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [September 12, 2017, 4:58am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/6 "2017-09-12T04:58:27Z")

</div>

@mkborregaard is there a page in the docs with tricks like this? They are extremely useful!

In the other post, you gave us the means to explore colorschemes of all kinds, now I learned how to find attributes in the Julia prompt, that is amazing! This should be at the top of the docs somewhere.

---

<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:** [September 12, 2017, 5:05am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/7 "2017-09-12T05:05:50Z")

</div>

E.g. the very top shiny blue box on this page 🙂 [https://juliaplots.github.io/attributes/](https://juliaplots.github.io/attributes/)

But agreed, some things in the docs (e.g. also the description of legends) could be improved. We often try to solicit PRs to the docs, as the readers of those are really the experts.

---

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [December 6, 2017, 5:32pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/8 "2017-12-06T17:32:41Z")

</div>

I found out that it is not working any more. I got the error message “mm not defined”. None of other units (px, in, etc) seems to work either. I am using Plots.jl v0.13.1 and RecipesBase 0.2.3. Does anyone know if the syntax has changed?

---

<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:** [December 6, 2017, 9:59pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/9 "2017-12-06T21:59:18Z")

</div>

It has, as we had too many namespace clashes. `using Plots.PlotMeasures` will resurrect the functionality.

---

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [December 7, 2017, 5:47am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/10 "2017-12-07T05:47:58Z")

</div>

Thank you. That’s what I needed to know.

---

<div class="post-metadata">

**Author:** ![mwsohn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mwsohn/32/2696_2.png) [@mwsohn](https://discourse.julialang.org/u/mwsohn)\
**Post date:** [December 7, 2017, 6:35am UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/11 "2017-12-07T06:35:15Z")

</div>

Another question. Is there a way to control the spacing between tick values and the axis?

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [November 27, 2018, 5:38pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/12 "2018-11-27T17:38:21Z")

</div>

I found that this doesn’t move change the distance between axes and label, instead it moves the adjacent plots, making a bad use of space. I’m using plotly, by the way. Does any one have any suggestion to achieve the change?

---

<div class="post-metadata">

**Author:** ![Shea\_Fitzgerald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shea_fitzgerald/32/8249_2.png) [@Shea\_Fitzgerald](https://discourse.julialang.org/u/Shea_Fitzgerald)\
**Post date:** [April 30, 2019, 7:19pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/13 "2019-04-30T19:19:04Z")

</div>

I’m having this same problem still and have found nothing.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [April 30, 2019, 10:47pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/14 "2019-04-30T22:47:38Z")

</div>

Easy to do with [GMT.jl](https://github.com/GenericMappingTools/GMT.jl) Didn’t really understand if you are referring to annotations or labels so I give here examples for the two.

Change Label offset with the `MAP_LABEL_OFFSET` parameter

```julia
basemap(region=(0,10,0,10), frame=(axes=:Wsen, annot=:auto, label="Y Label"), figsize=10, par=(:MAP_LABEL_OFFSET, "30p"), show=true)

```

Change annotation offset with the `MAP_ANNOT_OFFSET` parameter

```julia
basemap(region=(0,10,0,10), frame=(axes=:Wsen, annot=:auto), figsize=10, par=(:MAP_ANNOT_OFFSET, "30p"), show=true)

```

 ![label](https://global.discourse-cdn.com/julialang/original/3X/c/8/c8200725b3df968fdfdc8a8a8f8b6aff44a5ca3b.png) ![annot](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b07f6cbf17fe94c0e9b5d4118cb16dabdd17635.png)

---

<div class="post-metadata">

**Author:** ![Andre\_Mello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andre_mello/32/7333_2.png) [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Post date:** [July 9, 2020, 6:44pm UTC](https://discourse.julialang.org/t/in-plots-jl-how-does-one-control-the-space-between-ylabel-and-yaxis/5717/15 "2020-07-09T18:44:46Z")

</div>

I was brought here by a Google search because I had something like the following graph:

```julia
using LaTeXStrings
using Plots
pyplot()

a = [1e-5, 2e-5, 3e-5, 4e-5, 5e-5]
b = [1e5, 2e6, 3e7, 4e8, 5e9]
c = [1e8, 2e9, 3e10, 4e10, 5e10]

plot(a, b, c,
     camera=(-100,30),
     xlabel=L"\Theta_1", ylabel=L"\Theta_2", zlabel="Z Label",
     xtickfont=(10), ytickfont=(10), ztickfont=(10))

```

 ![Figure_1](https://global.discourse-cdn.com/julialang/original/3X/4/c/4cf82bb74412f16f4d67a89412c992dbc296369c.png)

We can easily spot a couple of problems. The first one, which led me here, is the proximity between the labels and the ticks. Another problem is the xticks going through the graph, making the scientific notation almost unreadable.

After some tinkering I finally arrived at a good enough solution. I figured I’d share it here for future reference.

```julia
plot(a, b, c,
     camera=(-100,30),
     right_margin=10px,
     xlabel="\n\n\n"*L"\Theta_1", 
     ylabel="\n\n\n"*L"\Theta_2", 
     zlabel="\n\nZ Label",
     xtickfont=(10), ytickfont=(10), ztickfont=(10),
     xrotation=-45,
     zrotation=-45)

```

 ![Figure_2](https://global.discourse-cdn.com/julialang/original/3X/8/2/820fed58a9f485472b8e5b82a41da40b30ad93c9.png)

Essentially, what did the trick was rotating the ticks and putting some breaklines in the labels (which can be even more useful if you don’t need/want to rotate the ticks).
