Title basically says it all; I want to be able to control which color get associated with which number. I have tried the code stated below to give a color to every number from 0 to 5. The way I thought this code would work was that the first row of cmap would be the color for 0, the second for 1, the third for 2, etc. But it still seems to associate colors from cmap randomly to the numbers in the matrix A.
A=[1:3;2:4;3:5;0 0 0];cmap = [0 0.5 0.5;0.75 0.75 0;1 0.75 0.25; 0.25 0 1;1 1 0.75;0.75 0 0.75; 0.75 0.75 0;0.25 0.25 0.25;1 0.5 0];colormap(cmap);caxis([0 5]); imagesc(A);
Thanks for reading!
Best Answer