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

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

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

4 Likes

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

2 Likes

Thank you for this link - very helpful! :slight_smile:

1 Like

Thank you.

@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.

E.g. the very top shiny blue box on this page :slight_smile: 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.

2 Likes

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?

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

2 Likes

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

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

1 Like

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?

1 Like

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

Easy to do with 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

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

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

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

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))

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.

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)

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).

1 Like