Adding significance to boxplots and violin plots

I’m having the same question as here, but for Algebra of Graphics.

How can I add significance stars to boxplots?

Thanks!

After you call draw, you could modify the figure (global) with lower-level Makie. Mostly from LLM but appeared to work:

using CairoMakie, AlgebraOfGraphics
dataset = (
    group = repeat(["A", "B", "C"], inner=20),
    value = [randn(20) .+ 5; randn(20) .+ 6; randn(20) .+ 7]
)
function add_signif!(x, y, text)
    lines!([x[1], x[1], x[2], x[2]], [y-0.2, y, y, y-0.2], color=:black)
    text!((x[1] + x[2]) / 2, y, text=text, align=(:center, :bottom))
end
function plot_boxplots(d, x, y)
    spec = data(d) * mapping(x, y) * visual(BoxPlot)
    draw(spec)
    add_signif!((2,3), maximum(d[y])+1, "***")
    return current_figure()
end
plot_boxplots(dataset, :group, :value)