Question

I have a 2d array that has values -1 and 1. How do I make the imagesc(lattice) appear in 2 specific colours? Right now it shows red for -1, blue for 1, and green for 0. I want to make the places with 0 appear white.

Was it helpful?

Solution

sounds like you need to set the colormap. If you only have three values, you might set:

cmap = [0 0 1; 1 1 1; 1 0 0]; % sets the colors to blue, white, red\
imagesc(data); colormap(cmap);

OTHER TIPS

You need to set the colormap with those three colors:

cmap = [0 0 1; %// blue
        1 1 1; %// white
        1 0 0] %// red
colormap(cmap)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top