I’ve also seen plots where people use an uneven scale on a symmetrical colormap. So you don’t distort the map but the scale. Here’s an example I cooked up a while ago, adjusted to your numbers:
data = rand(10, 10) .* 4
f = Figure()
ax = Axis(f[1, 1])
upper = 4
lower = 0
midpoint = 1
ratio = (upper - midpoint) / (midpoint - lower)
sc = ReversibleScale(
x -> x > midpoint ? (x - midpoint) / ratio + midpoint : x,
x -> x > midpoint ? (x - midpoint) * ratio + midpoint : x
)
hm = heatmap!(ax, data, colorscale = sc, colorrange = (lower, upper), colormap = :delta)
Colorbar(f[1, 2], hm, ticks = lower:upper)
f
Here’s a variant with the upper part going to 10, to show the effect even more:
upper = 10
lower = 0
midpoint = 1
data = rand(10, 10) .* (upper - lower) .+ lower
f = Figure()
ax = Axis(f[1, 1])
ratio = (upper - midpoint) / (midpoint - lower)
sc = ReversibleScale(
x -> x > midpoint ? (x - midpoint) / ratio + midpoint : x,
x -> x > midpoint ? (x - midpoint) * ratio + midpoint : x
)
hm = heatmap!(ax, data, colorscale = sc, colorrange = (lower, upper), colormap = :RdBu)
Colorbar(f[1, 2], hm, ticks = lower:upper)
f
Might be confusing to some readers though.
Edit: hmm seems like the rendering of the colors in the heatmap is a bit off though with this
Edit2: I just had forgot to scale the input data with the larger limits, I think