Could I change the color of specific point?

Hi, all
I have a matrix 49x49,
It's contains 0~10000 value.
When I plot this matrix, use colorbar.
But the zero value point,I want to use white color to present this point.
How can I do?
Thanks.

3 Kommentare

Richard
Richard am 28 Nov. 2012
does it matter what all the other colors are? i.e. do you require them to be in color or will balck and white be ok? If balck and white are ok you could just alter the colormap of your plot to gray: http://www.mathworks.co.uk/help/matlab/ref/colormap.html
BB
BB am 28 Nov. 2012
Other color is use "colorbar" this command
only zero value use white
Jan
Jan am 28 Nov. 2012
When you post the relevant part of your code, inserting modifications is much easier. Test data can usually created by RAND.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 28 Nov. 2012

0 Stimmen

Get the colormap, set 0 to white, then reapply it.
cm = colormap;
cm(0, :) = [255 255 255];
colormap(cm);

5 Kommentare

BB
BB am 28 Nov. 2012
when I evaluate
cm(0, :) = [255 255 255];
It's occur error
"Subscript indices must either be real positive integers or logicals."
Image Analyst
Image Analyst am 28 Nov. 2012
Sorry, I meant cm(1,:) - the first row which corresponds to gray level 0.
BB
BB am 28 Nov. 2012
Bearbeitet: BB am 28 Nov. 2012
Sorry= =
I key this code
cm = colormap;
cm(1, :) = [255 255 255];
colormap(cm);
It's still occurs error
"Colormap must have values in [0,1]."
:(
Image Analyst
Image Analyst am 28 Nov. 2012
That's right. The values must be in the range 0-1, not 0-255 even though it's really 255. So try this:
cm(1, :) = [1 1 1];
BB
BB am 28 Nov. 2012
ok,it's looks good. thank you~

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Color and Styling finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by