# CairoMakie Legend Line Too Short

**URL:** <https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990>\
**Category:** Visualization\
**Tags:** makie, cairomakie\
**Created:** [March 1, 2024, 4:08am UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990 "2024-03-01T04:08:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [March 1, 2024, 4:08am UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/1 "2024-03-01T04:08:49Z")

</div>

Hello,

I am trying to determine how I can increase the line thickness of the lines in the legend.

Please consider the following MWE and resulting image. The lines in the legend are too short and it is hard to tell which is dashed and which is solid (I realize in this case the markers can be used to discern them, please ignore that for the sake of the example).

How can I increase the little segments of line in in the legend so it is clearer which line style corresponds to which legend entry?

```julia
using CairoMakie, LinearAlgebra

x = LinRange(0, 1, 10)
y1 = sin.(2π * x)
y2 = x .^ 2

begin
    fig = Figure()
    ax = Axis(fig[1, 1])
    scatterlines!(x, y1, label="Line 1")
    scatterlines!(x, y2, label="Line 2")
    axislegend("My Legend", position=:lb)
    fig
end

```

![mwe](https://global.discourse-cdn.com/julialang/original/3X/2/b/2b2c19a1f76ddaddc8af8df5a253854b384f4173.jpeg)

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 1, 2024, 4:37am UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/2 "2024-03-01T04:37:07Z")

</div>

This post made me laugh out loud. It’s like Makie is _trying_ to mess with you.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [March 1, 2024, 6:09am UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/3 "2024-03-01T06:09:55Z")

</div>

You can increase the width of the `patchsize` of the `Legend` which will increase the line widths as well.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 1, 2024, 10:01am UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/4 "2024-03-01T10:01:53Z")

</div>

> [@jar1](#):
>
> It’s like Makie is _trying_ to mess with you.

It’s far from the defaults though… I think @TI36XPro has a lot of configuration that’s not included in the MWE. With the given code I see this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/2/02fd62acdf6e80ec269efedf242db0cf57ff372e.png)

We can adjust the legend line length using `patchsize` as suggested by @jules, replacing the `axislegend` line with

```julia
axislegend("My Legend", position=:lb, patchsize=(50,20))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/e/9e8bb841d151bfb7cac72578da202228db2c8383.png)

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [March 1, 2024, 3:38pm UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/5 "2024-03-01T15:38:51Z")

</div>

I tried `axislegend("My Legend", position=:lb, patchsize=10)` and I get the following error `ERROR: BoundsError: attempt to access Int64 at index [2]`

Edit: Nevermind. Didn’t realize `patchsize` has to be a tuple. I’ve fixed it. Ended up using `patchsize=(50,10)` for now. Thank you!

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [March 1, 2024, 3:40pm UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/6 "2024-03-01T15:40:56Z")

</div>

Correct - I forgot I had a theme applied separately that is not included in the MWE. Although the theme makes no changes to `patchsize` so still not clear how or why it got so small. Either way, it is fixed!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [March 1, 2024, 5:11pm UTC](https://discourse.julialang.org/t/cairomakie-legend-line-too-short/110990/7 "2024-03-01T17:11:57Z")

</div>

> still not clear how or why it got so small

I think you just themed all the other stuff to be quite big 🙂
