How to make color bar and contour plot agree in makie?

Christopher_Fisher
Thu, 05 Mar 2026 21:52:12 +0000
General Usage

Hello. I was wondering how to change the color mapping in the example below. I thought I could change limits in the colorbar and the range of colors in the contour plot would adjust accordingly. Changing the lower limit, for example, does nothing, but update the color bar. Is there a way to make the contour plot and color bar agree?

using CairoMakie

xs = range(-10, 10, 500)
ys = range(-10, 10, 500)

zs = [x * y for x ∈ xs, y ∈ ys]
f = Figure()
ax = Axis(f[1, 1])
contourf!(xs, ys, zs)
Colorbar(f[1,2], limits = (-5000, 50))
f

3 posts - 2 participants