# Makie how to conditionaly hide a legend entry in \`axislegend\`

**URL:** <https://discourse.julialang.org/t/makie-how-to-conditionaly-hide-a-legend-entry-in-axislegend/139312>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [September 9, 2026, 3:08pm UTC](https://discourse.julialang.org/t/makie-how-to-conditionaly-hide-a-legend-entry-in-axislegend/139312 "2026-09-09T15:08:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [September 9, 2026, 3:08pm UTC](https://discourse.julialang.org/t/makie-how-to-conditionaly-hide-a-legend-entry-in-axislegend/139312/1 "2026-09-09T15:08:25Z")

</div>

I have a function that makes the plot on the left:

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

it achieve this via the standard `scatter!(xxx; label = "something")` infrastructure, after which I call `axislegend`.

I want to use the same plot on the right. On top of it I want to plot other elements with their legend entries. I don’t want to repeat the previous legend entries.

I thought doing the conditional `scatter!(xxx; label = add_legend ? "something" : "")` would solve things. but it doesn't because the legend entry is there.

I ask therefore: what is the _default_ keyword argument value for `label`? So that I can programmatically / conditionally hide some legend entries in `axislegend`?

---

<div class="post-metadata">

**Author:** ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Post date:** [September 9, 2026, 3:23pm UTC](https://discourse.julialang.org/t/makie-how-to-conditionaly-hide-a-legend-entry-in-axislegend/139312/2 "2026-09-09T15:23:09Z")

</div>

Not sure I fully understood what you want to accomplish here, but is this what you’re looking for?

```julia-auto
using GLMakie

xs = range(0, 2π; length = 501)
y1s = sin.(xs)
y2s = cos.(xs)

fig = Figure()
ax = Axis(fig[1,1])
lines!(ax, xs, y1s; label = "Base data")
add_legend = false 
lines!(ax, xs, y2s; label = add_legend ? "Additional data" : nothing)
axislegend(ax)
fig

```

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [September 9, 2026, 3:24pm UTC](https://discourse.julialang.org/t/makie-how-to-conditionaly-hide-a-legend-entry-in-axislegend/139312/3 "2026-09-09T15:24:00Z")

</div>

> [@JonasWickman](#):
>
> ```julia-auto
> xs = range(0, 2π; length = 501)
> y1s = sin.(xs)
> y2s = cos.(xs)
> 
> fig = Figure()
> ax = Axis(fig[1,1])
> lines!(ax, xs, y1s; label = "Base data")
> add_legend = false 
> lines!(ax, xs, y2s; label = add_legend ? "Additional data" : nothing)
> axislegend(ax)
> fig
> 
> ```

Yes thank you! I guess `nothing` is the obvious default keyword I should have tried first!
