how do I adjust the z scale on a contourf plot?

I am plotting my data with contourf. The max value is 35 and the minimum value is -24. I am not interesting in visualizing any data beyond +/-5. How can adjust the scale such that the color map is applied only to the range between -5 and +5?

댓글 수: 1

Angus
Angus 2013년 6월 21일
You dont want just caxis([-5 5]) do you? It will limit the colorscale, but will still display the rest of the data outside that.

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

답변 (2개)

Angus
Angus 2013년 6월 21일

0 개 추천

Probably not the best way but this works somewhat ...
val_range = double(data>=-5 & data<=5);
val_range(val_range==0) = NaN;
[C,h] = contourf(data.*val_range);
Kilian
Kilian 2013년 6월 21일

0 개 추천

Thanks, Angus, for your quick reply. Actually, caxis works fine. I tried your code with val_range, but that didn't work. I get the message: "Warning: Contour not rendered for non-finite ZData"
With caxis I didn't see it limit the color scale. I wish I could upload a screen shot for illustration. Thanks again for your help.

댓글 수: 1

Angus
Angus 2013년 6월 24일
Too bad about the code not working, not sure why exactly, I was trying to replace any values outside of -5/5 with NaNs, it seemed to work for me but it could fail under some circumstances, apparently :/
Well if caxis got things going for you then great, glad that worked.
Cheers

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

카테고리

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

제품

질문:

2013년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by