StatsPlot -- axes labels overwrite each other

That begs for two y-axes solutions using twinx().
Example:

using StatsPlots, Measures
x1 = LinRange(1.5, 1.6, 1000); y1 = rand(x1, 1000)
x2 = LinRange(1, 3, 1000); y2 = rand(x2, 1000)
density(y1, c=:red, label="left",legend=:topleft, right_margin=20mm)
density!(twinx(), y2, c=:green, label="right",legend=:topright, right_margin=20mm)

2 Likes