# Makie.jl: how to display labels on a waterfall chart

**URL:** <https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [January 13, 2025, 9:22pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742 "2025-01-13T21:22:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ajk/32/6137_2.png) [@ajk](https://discourse.julialang.org/u/ajk)\
**Post date:** [January 13, 2025, 9:22pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742/1 "2025-01-13T21:22:56Z")

</div>

Hi, I can’t figure out how to label the bars in a Makie waterfall chart anymore. It used to be possible to pass all barplot options to `waterfall(...)`, e.g. the following code used to run. Since updating I now have to comment out the `bar_labels` option. Any idea what to do?

```julia
    waterfall(pos, x, yvals ,axis = (xticks = (x, xlab), title="$(name)", limits = (nothing,nothing,ll,ul)),
    show_direction=false,
    # color_over_bar=:black,
    # color_over_background=:black,
    # bar_labels=[(y>0 ? "+"*string( round(y,digits=2))*"%" : 
    # y<0 ? string( round(y,digits=2))*"%" :
    # "") for y in yvals],
    dodge=group, color=colors[group], stack=x )

```

---

<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:** [January 14, 2025, 8:26am UTC](https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742/2 "2025-01-14T08:26:30Z")

</div>

There were some changes to disallow unknown attributes, even though some recipes might have just forwarded these to their children. But it led to unintended consequences too often. These attributes you’re setting have not been added specifically to `waterfall` so they are rejected. They could be added again, though, you’re welcome to file a PR to that effect.

A workaround would be to plot the waterfall, then access `wf.plots` which contains the underlying barplot. On this, you should be able to set the desired attributes. So something like `wf.plots[i_barplot].bar_labels = ...`

---

<div class="post-metadata">

**Author:** ![ajk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ajk/32/6137_2.png) [@ajk](https://discourse.julialang.org/u/ajk)\
**Post date:** [January 15, 2025, 8:04pm UTC](https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742/3 "2025-01-15T20:04:53Z")

</div>

Thanks! But unfortunately I still can’t get this to work. Maybe I am missing something.

If I call `wf=waterfall(...`,  
then I can manually set  
`wf.plot.plots[1].bar_labels = mybarlabels`, and this doesn’t throw an error, but the final chart doesn’t show any labels on the bars.

---

<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:** [January 16, 2025, 9:00am UTC](https://discourse.julialang.org/t/makie-jl-how-to-display-labels-on-a-waterfall-chart/124742/4 "2025-01-16T09:00:27Z")

</div>

Ah I see, the problem is that the `barplot` recipe adds the text plot for the labels only if at creation, `bar_labels !== nothing`. So you’re too late basically. Ideally such things would be dynamic as well but Makie tends to not implement dynamic plot addition/removal in recipes because it’s a bit finicky. The best thing would be to just add these attributes to `waterfall`, I’d welcome a PR to that effect.

Other than that, here’s a workaround. We just create the waterfall, then delete it again but re-plot the inner barplot using the attributes and args that waterfall created. But there we can add the `bar_labels` attribute:

```julia
f, ax, wf = waterfall(1:10)
delete!(ax, wf)
barplot!(ax, wf.plots[1].args...; wf.plots[1].attributes..., bar_labels = string.(1:10))
f

```

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