I use the :balance colorscheme with the ideally zero as white at the centre of Colorbar. The highest value is red and the lowest value is blue. If I have a range (-4.725205, 28.010359), I get around 10 at the centre of Colorbar, but I need to zero is still in the centre and everything highest or lowest will be interpolated to the red or blue. How can I fix the centre of Colorbar to zero?
The left image is an example of colorrange = (-4.725205, 28.010359) and the centre is calculated as 11,642577, what is I donāt want.
The right image is example with zero in the centre, but itās not fixed by programmer, itās only calculated as (-17.564026, 22.240145) => 22.240145 - (-17.564026) = 39,804171 => 39,804171 / 2 = 19,9020855 => The centre is 2,3380595.
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
Ok that is a different problem, yes if you need to have zero in your colormap and donāt use any nonlinear scale, you will have hard to discriminate values if they are far away from zero and close together.