KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

double y axes doesn't work in PGFPlotsX #254

Closed pstaabp closed 3 years ago

pstaabp commented 3 years ago

I was looking to plot with multiple items with different y-axes. I stumbled across:

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

from JuliaPlots/Plots.jl#2636. In GR this works fine (with some spacing issues), but using the PGFPlotsX backend, we get:

image

where both y-axes are on the left and the x-points of the two curves do not overlay.

Although from JuliaPlots/Plots.jl#594, it appears that twinx() is a hidden feature, it seems like there is interest in it.

tpapp commented 3 years ago

I think this is an issue with the Plots backend, not this package. @BeastyBlacksmith, can you transfer to the relevant repo?

pstaabp commented 3 years ago

I decided to add it here because it seems to work in the GR backend, so I thought it might be a PGFPlotsX issue instead.

tpapp commented 3 years ago

No problem, we really should make an effort to clarify this (cf #255). Given the information above, without delving into the internals of the backend (in Plots.jl) we cannot easily determine if this is a bug with PGFPlotsX per se, or the way the backend is using it.

KristofferC commented 3 years ago

Issues with Plots need to be reported to the Plots repo (until they are determined to be a bug with the backend, and in that case need to have an example that is directly using the backend, and not using the Plots wrappers).