How to add labels to grid of tricontourf! in GLMakie

Christopher_Fisher
Mon, 02 Mar 2026 17:11:45 +0000
General Usage

I am trying to add row and column labels to a grid of plots below. I am trying to adapt the solution here for my use case, but the plots are too small relative to the entire figure.

using GLMakie

x = randn(50)
y = randn(50)
z = x .* y

fig = Figure(backgroundcolor = :white)

for i ∈ 1:3
    Label(fig[i, 0], "row $i", color=:black, halign=:right, tellwidth=false)
    Label(fig[0, i], "column $i", color=:black, halign=:center, tellwidth=false)
end

for c ∈ 1:3, r ∈ 1:3
    ax = Axis(fig[r, c], aspect = DataAspect())
    tricontourf!(ax, x, y, z)
end
colgap!(fig.layout, 0)
rowgap!(fig.layout, 0)
display(fig)

When I remove the first loop for the labels, the subplots are the correct size. I am probably making a silly mistake, but I cannot figure out what it is.

3 posts - 2 participants