# How to pair together a Lines and a Band plot in Makie?

**URL:** <https://discourse.julialang.org/t/how-to-pair-together-a-lines-and-a-band-plot-in-makie/133800>\
**Category:** Visualization\
**Tags:** plotting, makie, wglmakie, glmakie\
**Created:** [November 11, 2025, 6:15pm UTC](https://discourse.julialang.org/t/how-to-pair-together-a-lines-and-a-band-plot-in-makie/133800 "2025-11-11T18:15:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [November 11, 2025, 6:15pm UTC](https://discourse.julialang.org/t/how-to-pair-together-a-lines-and-a-band-plot-in-makie/133800/1 "2025-11-11T18:15:36Z")

</div>

I have two dataseries where each of them also has associated uncertainty. I’m plotting the uncertainty as a translucent envelope around the main line plot of the series.

When using GLMakie/WGLMakie to interact with the figure, selecting a label in the legend turns that series on or off, but not the envelope around it. For example, the default view is

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/3/a38d41aa853926927f46f4a761302eddc8e98224.png)  
and if I want to only view the `y2` series, I can click on `y1` to toggle it/turn it off.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a260194d405e87f760e8865d68ab83284f27b03.png)  
But this still keeps the band around the line. How do I tell Makie that the line plot and the band are paired, and if I toggle one from the legend, both should be turned on/off?

I can also pass in `label = "..."` to `band`, but that just creates a new label and the pairing objective is still not fulfilled.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/5/f5e44fc65de6d88708ca05041cf9f88270a1c467.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/9/b9927df87b18ab2b23e155df517da19d2ebd07b0.png)

Minimal working example:

```julia
using WGLMakie

n = 30
x = range(0, 5, length=n)

y1 = 10 .+ rand(n)
y2 = 12 .+ rand(n)
y1_σ = abs.(rand(n) .- 0.5)
y2_σ = abs.(rand(n) .- 0.6)

let
    fig = Figure()
    ax = Axis(fig[1,1])

    lines!(ax, x, y1, label = "y1")
    band!(ax, x, y1-y1_σ, y1+y1_σ, alpha = 0.4)

    lines!(ax, x, y2, label = "y2")
    band!(ax, x, y2-y2_σ, y2+y2_σ, alpha = 0.4)

    axislegend(ax)

    fig
end

```

(Created in a Pluto.jl notebook)

Edit: Forgot to put `abs()` for the uncertainties, that’s why there’s some darker shaded regions in the plot

---

<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:** [November 11, 2025, 9:57pm UTC](https://discourse.julialang.org/t/how-to-pair-together-a-lines-and-a-band-plot-in-makie/133800/2 "2025-11-11T21:57:32Z")

</div>

What happens if you use the `merge` option of axislegend?

---

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [November 11, 2025, 10:08pm UTC](https://discourse.julialang.org/t/how-to-pair-together-a-lines-and-a-band-plot-in-makie/133800/3 "2025-11-11T22:08:19Z")

</div>

Yup! That’s exactly what I needed. Thank you!!!

For future reference: the solution is

```julia
lines!(ax, x, y1, label = "y1")
band!(ax, x, y1-y1_σ, y1+y1_σ, alpha = 0.4, label = "y1") # the same label text
# ...
axislegend(ax, merge = true)

```
