-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
Plot(twinx(), ...) creates ylabel on the wrong side of the plot (left instead of right) #1276
Comments
I also bumped into this. I hope someone fixes it.. |
Guys, I am faced with this problem, too. |
I would gladly address this if someone pointed me in the right direction. Upon inspection, If you try to run
you will see that the plot has no mirrored label. Therefore I think that this is a bit of a deeper problem in GR(). |
It is likely not in GR, but in the backends/gr.jl file of Plots |
@mkborregaard Thanks. You were right: It was a very easy fix.
should become
Could you point me out towards the best way to commit it back to the community? Should I create a PR? |
Yes, please submit a PR! If you need guidance, feel free to ask or read http://docs.juliaplots.org/latest/contributing/#git-fu-or-the-mechanics-of-contributing |
I submitted a PR. Moreover, I took the liberty of changing the code that computes the padding to add the padding to the side where the label is actually located. Please let me know if the PR is not well done or if I should do something else. |
Does this now work for others? It doesn't fully work for me... When I run using Plots
x=1:20
y1=rand(length(x))
y2 = sin.(x)
plot(x,y1,label = "My y1 label", legend = :topleft, ylabel = "the lh y-axis",grid=:off)
plot!(twinx(),y2, label = "my y2 label", legend=:topright, ylabel = "the rh y-axis", grid=:off, xlabel="numbers", color=:red, box=:on) I get a plot with no label on the right hand y-axis. I'm not sure if it's off the plot to the right or missing (less likely). Apologies for not using the "Insert code" tool. When I used it and previewed this message it seemed to ignore newlines... Edit: It's also the case that a graph such as the one above cannot be included as a subgraph with layout. If Ichange the code above: using Plots
x=1:20
y1=rand(length(x))
y2 = sin.(x)
p1=plot(x,y1,label = "My y1 label", legend = :topleft, ylabel = "the lh y-axis",grid=:off)
plot!(p1,twinx(),y2, label = "my y2 label", legend=:topright, ylabel = "the rh y-axis", grid=:off, xlabel="numbers", color=:red, box=:on)
p2 = plot(1:10,1:10)
plot(p1,p2, layout = (1,2) then I get an error: This is true in both Atom+Juno and Pluto. Not sure about different backends (although I know the rh y-axis problem is there with Plotly as well as Gr). |
In my question about visualization on the julia discourse website (https://discourse.julialang.org/t/overlay-plot-with-second-plot-with-second-y-axis-to-the-right/6558) an issue occured that was identified as a bug by @mkborregaard:
When using
plot(twinx()...)
the ylabel does not appear on the right side (as it should) but on the left side, on top of the original ylabel.The text was updated successfully, but these errors were encountered: