how do I adjust the z scale on a contourf plot?
5 次查看(过去 30 天)
显示 更早的评论
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
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
2013-6-21
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);
0 个评论
Kilian
2013-6-21
1 个评论
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!