Imagesc plot (dividing the colorbar to blue-green, white, and green-red range)
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Image Analyst
2014-5-10
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 个评论
Image Analyst
2014-5-10
How about an interactive way of creating one? Have you tried colormapeditor ()?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!