In Makie, how do I change the background for parts of the axis

I would like to change the background e.g. from x=a to x=b to purple, I can sort of use the band! to achieve the visual,

using GLMakie

ts = 0:0.01:2π
dat = sin.(ts)

fig = Figure()

ylims = extrema(dat) .+ (-0.1, 0.1)
ax = Axis(fig[1, 1], limits=((0, 2π), ylims))
lines!(ts, dat)
band!(π:0.01:2π, ylims[1], ylims[2], color=(:purple, 0.2))

fig

But is there some better/less-hacky methods? Thanks!

Found the documentation

https://docs.makie.org/stable/reference/plots/hvspan/#hspan_and_vspan

2 Likes