ENOK
ENOK

Reputation: 1

How do I change a single color in a colormap in Matlab?

I've got a series of data in a regular x by z matrix that I am plotting using pcolor in Matlab. I am using the JET color map (flipped upside down) and would like to know how I can specify that when ever the parameter I am plotting has a value of 0, then the color should be white instead of the default dark red?

My data is not filling out the entire matrix, so all cells without data are set to 0. This provides a plot which is semi-satisfactory as the contrast between the datafilled cells and the 0-cells is great enough that the area covered by the data is easily identified. However it would enhance the image greatly if all 0-cells where plotted in white.

Best wishes ENOK

Upvotes: 0

Views: 3660

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272717

You can get an array representing the colormap:

map = colormap('jet');

You can then modify individual rows as required, and then set the colormap:

colormap(map);

Upvotes: 4

Related Questions