Zero at center of Colorbar

It’s not precisely what I talking about, but it works. The main disadvantage is when the changes in values are too small. It makes the colorrange so huge and can hide these small changes in values.


The first image is original.
The second image is after applied own calculation of the range.

On the other side, the symmetry is so good. I have the three scenarios with values. Only negative, only positive and combined. The zero is the common point for each of them.

function set_colormap!(hm)
        if hm.colorrange[][1] >= 0
            hm.colorrange[] = (0, 1) .* maximum(abs, hm.colorrange[])
            hm.colormap = :amp
        else
            if hm.colorrange[][2] > 0
                hm.colorrange[] = (-1, 1) .* maximum(abs, hm.colorrange[])
                hm.colormap = :balance
            else
                hm.colorrange[] = (-1, 0) .* maximum(abs, hm.colorrange[])
                hm.colormap = :ice
            end
        end

        println(hm.colorrange[][1], ", ", hm.colorrange[][2])
end