Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The label of the second y axis on the right is partially missing #2636

Closed
hurricane007 opened this issue Apr 26, 2020 · 7 comments · Fixed by #4488
Closed

The label of the second y axis on the right is partially missing #2636

hurricane007 opened this issue Apr 26, 2020 · 7 comments · Fixed by #4488

Comments

@hurricane007
Copy link

hurricane007 commented Apr 26, 2020

Hello,
there is one strange behavior when plotting the second y-axis. for example, the code below gives a figure whose right y label is partially cut.

using Plots, LaTeXStrings
a = 1:10
b = rand(10)
plot(a,b, label = "randData", ylabel = "Rand data",color = :red, 
    legend = :topleft, grid = :off, xlabel = "numbers")
p = twinx()
plot!(p,a,log.(a), label = L"log(x)", legend = :topright, 
     box = :on, grid = :off, ylabel = "y label 2")

image
However, if we added a savefig after, the second y label magically shown up.
Does anyone know what is the reason?
In addition, is it possible to add an example of drawing the second y-axis in the tutorial?
image

@BeastyBlacksmith BeastyBlacksmith transferred this issue from JuliaPlots/PlotDocs.jl Apr 26, 2020
@BeastyBlacksmith
Copy link
Member

Is it correct, that this is using the GR backend in a jupyter notebook?

@BeastyBlacksmith
Copy link
Member

I can confirm that this also happens with GR from the terminal, but I can resize the window to fit the label.

@hurricane007
Copy link
Author

I was using pyplot in notebook.
I tried in REPL and found the same behavior. It's possible to resize the window to show the right Y label.

@BeastyBlacksmith
Copy link
Member

duplicate of #2205

@BeastyBlacksmith
Copy link
Member

Solution would be to add the guidefontsize to the right margin

@jessebett
Copy link

I am also hitting this issue where it's cutting off axis labels.

@benfolsom
Copy link

benfolsom commented Aug 20, 2020

You can use the left_margin and right_margin commands. Note that it uses "mm" which is deprecated, so you need to load it from Plots.Measures or do as below.

a = 1:10
b = rand(10)
plot(a,b, label = "randData", ylabel = "Rand data",color = :red, 
    legend = :topleft, grid = :off, xlabel = "numbers",left_margin = 5Plots.mm, right_margin = 15Plots.mm)
p = twinx()
plot!(p,a,log.(a), label = L"log(x)", legend = :topright, 
     box = :on, grid = :off, ylabel = "y label 2",left_margin = 5Plots.mm, right_margin = 15Plots.mm)

(See Issue #220 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants