Rotating the axis label in GR makes the label go out of the plot

Here is my code

using Plots
using LaTeXStrings
a = randn(100,1);
b = sin.(a);

scatter(a,b,xlabel=L"x",ylabel=L"\sin(x)",
        framestyle = :box,
        legend=false,
        yguidefontrotation = -90
)

The label “sin(x)” goes outside the plot region.

image


If I use pyplot(), then the label rotates, but it does not use the LaTeX font anymore, so using pyplot() is not an option.

image

1 Like

I found a workaround. using Plots.PlotMeasures and left_margin works.

using Plots
using Plots.PlotMeasures
using LaTeXStrings
a = randn(100,1);
b = sin.(a);

scatter(a,b,xlabel=L"x",ylabel=L"\sin(x)",
        framestyle = :box,
        legend=false,
        yguidefontrotation = -90,
        left_margin = 35 px
)