Get a legend with twinx()

A possible workaround:

using Measures, Plots; gr()

x12=randn(10)
y12=1000*randn(10)
lcx =:blue; lwx=2
lcy =:red; lwy=3
plot([x12[1]], lc=lcy, lw=lwy, label="y12", right_margin=15mm)
plot!(x12, label="x12", lc=lcx, lw=lwx, legend=:topleft)
plot!(twinx(), y12, lc=lcy, lw=lwy, label="")

Plots_gr_twinx_single_legend

2 Likes