I’m facing a garbled plot when I do a dual-axis plot with multiple variables on right/secondary y-axis.
Here, I’m trying to do multiple lineplots on top of a barplot.
using Plots
using Plots.PlotMeasures
pyplot()
bar(rand(10), c=:white, right_margin=1cm)
plot!(twinx(), rand(10), label="v1")
plot!(twinx(), rand(10) * 10, label="v2")
I see following issues:
Line plots for both “v1” and “v2” are in the same color
Legend of “v1” is not drawn (I presume it’s hidden by “v2” legend)
Ticks on right y-axis are drawn twice, with different y-range
If I swap left/right y-axis (lineplots on left y-axis, barplot on right/secondary y-axis), then I get what I basically expect, but still unusable as barplot hides detail of all lineplots.
using Plots
using Plots.PlotMeasures
pyplot()
plot(rand(10), label="v1", right_margin=1cm)
plot!(rand(10) * 10, label="v2")
bar!(twinx(), rand(10), label="", c=:white)
This happens on both GR and PyPlot backend, and also happens on both Plots v1.16.5 and v1.17.0 (latest).
I’m about to submit a bug ticket, but want to check if I’m not doing something stupid - please let me know if this happens in your environment. Also, if there’s any workaround, please let me know!
It brought me new understanding of twinx(), that it can be used to create not only 2, but multiple (N>1) additional y-axis by giving different (x-)offset for each twinx()-ed y-axis. Also, while Makie is still foreign to me, it does have many stunning examples - I definitely should check it out.
Maybe a little bit divergent from this topic, but is Makie.jl easier to handle than Plots.jl? I am always struggling to use different backends for different intensions.