Hi,
I’m trying to add a colorbar for a contour plot with uneven spacing between the contour lines. The contour plot
using CairoMakie
fig = let
fig = Figure()
ax = Axis(fig[1, 1])
xrg = 0.0:0.01:1.0
yrg = -1.0:0.1:1.0
z(x, y) = x.^2 .+ y.^2
zvals = zeros(length(xrg), length(yrg))
for (ix_x, x) ∈ enumerate(xrg)
for (ix_y, y) ∈ enumerate(yrg)
zvals[ix_x, ix_y] = z(x,y)
end
end
cf = contour!(ax, xrg, yrg, zvals, levels=cat(0.1:0.05:0.3, 0.4:0.1:1.0, dims=1), labels=true, colormap=:hsv)
#Colorbar(fig[1, 2], cf)
fig
end
When I naively try to add a colorbar I get the error
ERROR: Multiple colormaps found for plot MakieCore.Text{Tuple{Vector{Point{2, Float32}}}}, please specify which one to use manually. Please overload `Makie.extract_colormap(::MakieCore.Text{Tuple{Vector{Point{2, Float32}}}})` to allow for the automatical creation of a Colorbar.
I also tried wrapping into a categorical colormap,, but get the same error.
Is there a good way of adding the colorbar with levels specified in the contour plot?