Multiple colobars

ArneSpang
Fri, 12 Jul 2024 14:10:20 +0000
Visualization

I am trying to make a plot with a heatmap in the background and contour plot of a different field on top. I could steal some ideas from this thread (Overlay a contour over a heatmap - #8 by lazarusA) and I get as far as this:

using CairoMakie
x   = y = 1:0.2:20
f1(x,y) =    (x + 2y^2) * abs(sin(y) + cos(x))
f2(x,y) = -10(x + 2y^2) * abs(sin(x) + cos(y))
z1  = [f1(x,y) for x in x, y in y]
z2  = [f2(x,y) for x in x, y in y]
fig = Figure(resolution=(350,300), fontsize = 14)
ax1 = Axis(fig, aspect = 1, xlabel = "x", ylabel = "y")
p1  = heatmap!(ax1, x, y, z1, colormap=:plasma)
p2  = contour!(ax1, x, y, z2, colormap=:roma)
fig[1,1] = ax1
fig

But I don’t manage to get two colorbars. If I try this:

cb1 = Colorbar(fig, p1, width = 10, height = Relative(0.8), ticklabelsize = 10, tickalign = 1)
cb2 = Colorbar(fig, p2, width = 10, height = Relative(0.8), ticklabelsize = 10, tickalign = 1)

I get:
ERROR: Multiple colormaps found for plot MakieCore.Text

9 posts - 3 participants