Makie/CairoMakie custom colorbar ticks (> and <)


I’d like to customize my Colorbar() ticks in Makie/CairoMakie

I have reduced the colorrange on a graph since I have outliers that I do wish to display but don’t wish to have impact my colormap. Currently the ticks on the bar are the same as the colorrange even though this is actually inaccurate.

In reality they are from “< min value” to “> max value”. The rest of the ticks can of course be regular. Something like matplotlib’s

I have not so far managed to find this in the docs so any help is welcome! Thanks!

You can adjust the ticks and ticklabels of colorbars in (at least) two ways. At construction:

xs = ys = range(-1, 1, length = 101)
Z = xs.^2 .+ ((ys)').^2
fig = Figure()
ax = Axis(fig[1,1])
hm = heatmap!(ax, xs, ys, Z)
cbar = Colorbar(fig[1,2], hm; ticks = ([0.5,1.0,1.5], ["Low","Medium","High"]))

or after construction:

cbar.ticks[] = ([0.5,1.0,1.5], ["0.5","1.0","1.5"])

I could not fully understand what problem you are trying to solve specifically, please provide an MWE (Please read: make it easier to help you) if the above is not sufficient to solve your problem.

That’s perfect, thank you. I didn’t realize I could put two arrays into ticks like that.