Imagesc plot (dividing the colorbar to blue-green, white, and green-red range)
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to plot the values of a matrix ranging from -10 to 10 in a way that I can assign
1) Dark blue color to * green * to the values between -10 and -5
2) White color to values between -5 and 5
3) * Green * to dark red to values between 5 and 10
It is important that I do not like to miss any color in the range of white; i.e., step 3 must begin with the color that step 1 ends with.
I could write the following which is able to plot values of a matrix which are zero or positive and assign green to red color to values larger than 0.
A=[9 9.1 8.3 0 0;
0 9.5 8.4 0 0;
0 0 9.6 8.3 8.1;
0 7.1 7 9.7 0];
lowestValue = min(A(A(:)>0))
highestValue = max(A(:))
imagesc(A);
cmap = jet(256);
colormap(cmap(120:256,:));
caxis(gca,[lowestValue-2/256, highestValue]);
for i=1:120
cmap(i,:)=[1,1,1];
end
colormap(cmap(120:256,:))
colorbar
0 Kommentare
Antworten (1)
Image Analyst
am 10 Mai 2014
Do you have a question? I mean other than how do I format my code properly? And if you wanted a colormap like you said, why did you use jet(256)? And did you know that i does not appear in your loop anywhere so you're just setting the same row #120 over and over again 120 times?
2 Kommentare
Image Analyst
am 10 Mai 2014
How about an interactive way of creating one? Have you tried colormapeditor ()?
Siehe auch
Kategorien
Mehr zu Colorbar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!