bast
December 25, 2024, 9:37pm
1
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
bast
December 27, 2024, 3:04pm
3
Thanks, that is a good idea!
BLI
December 27, 2024, 10:30pm
4
Is there an attribute legend_linewidth
in Plots.jl
? I haven’t seen the documentation of it… Does it work with all backends?
BLI:
legend_linewidth
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")