# Linestyles look the same in legend

**URL:** <https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170>\
**Category:** General Usage\
**Tags:** plotting, plots\
**Created:** [December 25, 2024, 9:37pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170 "2024-12-25T21:37:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bast](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bast](https://discourse.julialang.org/u/bast)\
**Post date:** [December 25, 2024, 9:37pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/1 "2024-12-25T21:37:24Z")

</div>

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

```julia
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)

```

 ![test](https://global.discourse-cdn.com/julialang/original/3X/4/3/43ce864b0e295d0adf01fad850669fa663358d80.png)

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 26, 2024, 9:23am UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/2 "2024-12-26T09:23:55Z")

</div>

> [@bast](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![bast](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bast](https://discourse.julialang.org/u/bast)\
**Post date:** [December 27, 2024, 3:04pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/3 "2024-12-27T15:04:37Z")

</div>

Thanks, that is a good idea!

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [December 27, 2024, 10:30pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/4 "2024-12-27T22:30:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 27, 2024, 10:39pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/5 "2024-12-27T22:39:30Z")

</div>

> [@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.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [December 29, 2024, 11:16pm UTC](https://discourse.julialang.org/t/linestyles-look-the-same-in-legend/124170/6 "2024-12-29T23:16:13Z")

</div>

> [@bast](#):
>
> After increasing the linewidth the linestyles in the legend are indistinguishable:

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

```julia
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")

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/d/6d8404ef741c0c4263d47dffbf56777615f58942.png)
