# Makie series plot with only one label for legend?

**URL:** <https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 25, 2023, 11:18pm UTC](https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403 "2023-10-25T23:18:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew3245](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@matthew3245](https://discourse.julialang.org/u/matthew3245)\
**Post date:** [October 25, 2023, 11:18pm UTC](https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403/1 "2023-10-25T23:18:06Z")

</div>

Does anyone know if its possible to make a series plot that includes only one label for the whole series (instead of an array of labels that get displayed on the legend).

For example, say I had some experimental trial data as follows:

```julia
using GLMakie

trial_1 = [1, 5, 3]
trial_2 = [2, 9, 1]
trial_3 = [4, 2, 7]
trials = [trial_1 trial_2 trial_3]

```

Now I want to plot the mean of these trials as well as the separate trials as follows:

```julia
fig, ax = series(trials, solid_color=(:red, 0.3))
lines!(ax, vec(mean(trials, dims=1)), color=:red, label="mean")
axislegend(ax)
fig

```

 ![Screenshot from 2023-10-26 09-10-06](https://global.discourse-cdn.com/julialang/original/3X/9/f/9f4b0b4abaf5feee339222a7ba0811866c9325e9.png)

The legend currently displays, “series 1”, “series 2”, and “series 3”. Ideally, I’d want this to display just one label named “trials” (so there would only be two legend entries: “trials” and “mean”).

Any help is appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [October 26, 2023, 3:52am UTC](https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403/2 "2023-10-26T03:52:55Z")

</div>

Have you tried the `merge` keyword as described in the docs ([Legend · Makie](https://docs.makie.org/stable/reference/blocks/legend/#creating_a_legend_from_an_axis))?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/7/c7bc68a17cdfef0a44f36d89b50f003eb418cd6c.png)

---

<div class="post-metadata">

**Author:** ![matthew3245](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@matthew3245](https://discourse.julialang.org/u/matthew3245)\
**Post date:** [October 26, 2023, 4:26am UTC](https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403/3 "2023-10-26T04:26:42Z")

</div>

Yeah cheers, I did know about the merge keyword, but my problem was that I couldn’t input a single label for all the series plots.

But now using merge at least I can input an array of the same labels and it will work as I want:

```julia
fig, ax = series(trials, solid_color=(:red, 0.3), labels=repeat(["trials"], 5))
lines!(ax, vec(mean(trials, dims=1)), color=:red, label="mean", linewidth=4)
axislegend(ax, merge=true)
fig

```

 ![Screenshot from 2023-10-26 14-26-14](https://global.discourse-cdn.com/julialang/original/3X/9/6/96a68c49b7517a7efbbac998aaa2e45da211a174.png)

---

<div class="post-metadata">

**Author:** ![math4mad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math4mad/32/49486_2.png) [@math4mad](https://discourse.julialang.org/u/math4mad)\
**Post date:** [November 2, 2023, 5:13am UTC](https://discourse.julialang.org/t/makie-series-plot-with-only-one-label-for-legend/105403/4 "2023-11-02T05:13:16Z")

</div>

use Legend

```julia
using GLMakie, Statistics

trial_1 = [1, 5, 3]
trial_2 = [2, 9, 1]
trial_3 = [4, 2, 7]
trials = [trial_1 trial_2 trial_3]

colors = [:blue, :red]
function plot_res()
    fig = Figure()
    ax = Axis(fig[1, 1])
    series!(ax, trials, solid_color=colors[1])
    lines!(ax, vec(mean(trials, dims=1)), color=colors[2], label="mean")
    elems = [PolyElement(color=c, strokecolor=:blue, strokewidth=1) for c in colors]
    Legend(fig[1, 2], elems, ["Trials", "Mean"])
    fig

end
plot_res()

```

 ![one-label](https://global.discourse-cdn.com/julialang/original/3X/8/8/88dbe21b84bcd56cfa72ca9fd9b9d6294a173e61.png)
