At a guess, I would say that you need to have an amount of rows per color proportional to the size of each range. So 0
->0.683
is a lot bigger than 0.683
->0.9545
. In your color map you have provided only one row each so Matlab assumes that those colors should be assigned equally over the full range (i.e. 0
->1
) which with 4 colors means that red is for 0
->0.25
, blue is for 0.25
->0.5
etc...
Try something like this answer: How to create a custom colormap programmatically? but instead of using linspace
, use repmat
. You'll need to have enough rows to account for your 4 decimal point precision (which you might want to rethink) so in total you'll have 10 000 rows:
red = repmat([1 0 0], 6830, 1);
blue = repmat([0 0 1], 9545 - 6830, 1);
green = repmat([0 1 0], 9973 - 9545, 1);
white = repmat([1 1 1], 10000 - 9973 , 1);
map = [red;blue;green;white];
colormap(map);
or alternatively:
map = zeros(10000,3);
map(1:6830,1) = 1;
map(6831:9545,3) = 1;
map(9546:9973,2) = 1;
map(9974:end,:) = 1;