Manual colorbar location with Makie

If you specify a bbox you shouldn’t do Colorbar(fig[1, 2]) because that also sets the bbox using the layout mechanism. It’s either or.

x = LinRange(-1.0, 3, 200)
y = LinRange(-2.0, 2.0, 100)
Lx, Ly = x[end]-x[1], y[end]-y[1]
# One continuous field 
f = 1e3.*exp.(-x.^2  .- (y').^2)
# One discontinuous field 
g = zero(f)
g[(x.^2 .+ (y.^2)') .< 0.5^2] .= 1.0
# Compose figure
fig = Figure(resolution = (600, 600), fontsize = 22, fonts = (;regular="CMU Serif"))
ax = fig[1, 1] = Axis(fig, xlabel = L"x", ylabel = L"y", aspect=Lx/Ly)
hm = heatmap!(ax, x, y, f, colormap = (:plasma))
contour!(ax, x, y, g)

Colorbar(fig, hm, label = L"\log_{10}[(u^2+v^2)^{1/2}]", width = 20,
    labelsize = 14, ticklabelsize = 14, bbox=ax.scene.px_area,
    alignmode = Outside(10), halign = :right, ticklabelcolor = :white, labelcolor = :white,
    tickcolor = :white)

fig

2 Likes