Problem using margin on plots

Hey everyone,

I have the following problem. I want to plot something and use the Unicode symbol for beta as xlabel. However, it gets cut off like this:

using Plots; pyplot();
plot(rand(10))
xlabel!("\beta") 

image

It seems to me, that I should adjust the bottom margin like this:

using Plots; pyplot();
plot(rand(10), bottom_margin = 10mm)
xlabel!("\beta") 

like in the documentation here: http://docs.juliaplots.org/latest/examples/pyplot/#layouts-margins-label-rotation-title-location

This gives me however the following error:

<strong>UndefVarError: mm not defined</strong>

in top-level scope at [base\none](#)

Does anybody know what to do?

Thanks a lot!

5 Likes

I have ran into this problem before! There is some package or something you have to enable to be able to use the mm notation. I will try to remember what it is (although someone might beat me to the punch).

Found it. Add using Plots.PlotMeasures and the mm notation should work.

6 Likes

Thanks, that got rid of the error message, but didn’t solve my problem. Now there is more space below the beta, but its top is still cut off. :confused:

Hmm, this seems to be particular to the PyPlot backend. Other backends increase the margin between the label and axis but PyPlot pads below the label instead. If you try another backend (GR, Plotly, etc.) you can do what you want.

FYI, how about trying

gr(display_type=:inline)

befor plot()?

this doesn’t work for the gr backend :​(

It definitely works. I tested this on Plots v1.39.0.