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!