Is there a way to fix specific values to specific colors?
Yes, this is exactly what the example I provided does...
How is it different from the previous case? Your original data matrix has to be re-conditioned in order to represent an indexed image, i.e. a matrix in which each number represents a row in a given colormap:
## The original data with two continuous sections and discrete values in between
data = "" (100, 50) + 1), (rand (100, 50) + 5)];
data(rand(100) < 0.1) = 3;
data(rand(100) < 0.1) = 4;
## The colormap you want
nlev = 50;
redblue = [linspace(0,1,nlev)',zeros(nlev,1),fliplr(linspace(0,1,nlev))'];
orangepurple = [fliplr(linspace(0,1,nlev))',fliplr(linspace(0,0.5,nlev))',linspace(0,0.75,nlev)'];
cmap = [redblue; 0 1 0; 1 0.5 0; orangepurple];
## Now manipulate the data for plotting
data(data == 3) = nlev + 1;
data(data == 4) = nlev + 2;
data(data<3) = (data(data<3) - 1) * (nlev-1) + 1;
data(data<7 & data >=5) = nlev + 2 + (data(data<7 & data >=5) - 5) * (nlev-1) + 1;
imshow (data, cmap, "xdata", (-10:10), "ydata", (-10:10))
colorbar
Pantxo