I am wanting to contour an xy plane with z values. The particular data that I am analyzing is conduction velocity. I have been able to set up the contour plot the way I am wanting but am having trouble with modifying the colors that it is displaying. I am wanting to color the map in Green for areas that have a CV above a particular value and Red in areas when the CV falls below that value.

답변 (1개)

Star Strider
Star Strider 2016년 4월 18일
편집: Star Strider 2016년 4월 18일

1 개 추천

See if this does what you want:
[X,Y] = meshgrid(-10:10);
Z = X.^2 + 0.1*Y.^3; % Create Data
figure(1)
contourf(X, Y, Z, [min(Z(:)); 10]) % Use The ‘10’ Contour As The Cutoff
colormap([1,0,0; 0,1,0]) % Define Colours In ‘colormap’
figure(2)
surf(X, Y, Z)
grid on
colormap([1,0,0; 0,1,0])
The surf plot is there simply to demonstrate that the contourf call does what you want. The surf plot does not use a specific cutoff. See the documentation for contourf for a full description of how this particular call to it works.

댓글 수: 4

Thomas Shannon
Thomas Shannon 2016년 4월 18일
Hey thanks! This is great. Do you mind explaining how you are crating the data/why?
Star Strider
Star Strider 2016년 4월 18일
My pleasure!
Since I don’t have your data to work with, I create (not ‘crate’ — I didn’t see the typo) data to test the code to be certain it works. If possible, I always test the code I post. If for whatever reason I can’t, I clearly label it as untested code.
The ‘Q1’ assignment (now eliminated in the edited version, and the comment corrected) was a test line that I did not intend to include in the posted code.
Osvaldo
Osvaldo 2021년 3월 11일
Amazing!
Star Strider
Star Strider 2021년 3월 11일
Osvaldo — I very much appreciate your compliment!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

질문:

2016년 4월 18일

댓글:

2021년 3월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by