Linestyles look the same in legend

After increasing the linewidth the linestyles in the legend are indistinguishable:

using Plots 
testplt = plot(0:0.1:1, rand(11), label="dashdot", ls=:dashdot, color=:black, lw=4)
plot!(0:0.1:1, rand(11), label="dash", ls=:dash, color=:black, lw=4)

Is there a way to make sure that the full linestyle is visible in the legend?

A workaround is to plot thick lines, but use a line width of 1 in the legends.

1 Like

Thanks, that is a good idea!

Is there an attribute legend_linewidth in Plots.jl? I haven’t seen the documentation of it… Does it work with all backends?

Not that I know of.
The way I would do it is just to plot each thick line without a legend, followed by a plot of an empty point with a line width of 1, but the appropriate line style and legend.

1 Like

FWIW, if I save the plot as an SVG, the legend looks OK (well, better at least):

testplt = plot(0:0.1:1, rand(11), label="dashdot", ls=:dashdot, color=:black, lw=4)
plot!(0:0.1:1, rand(11), label="dash", ls=:dash, color=:black, lw=4)
savefig("testplt.svg")