Colorbar and m_contourf.m: Setting user-defined color ranges
2 次查看(过去 30 天)
显示 更早的评论
I'm using m_contourf.m to produce contour maps (lat, lon) of a scalar field, e.g. surface temperature. I'm struggling to produce a colorbar that can do all of the following. Can someone help me out here?
- horizontal colorbar for a map plot
- red: if value < -0.1
blue: if larger than 0.1
white: if in between -0.1 and +0.1
white: if value is NaN
grey: if value is -999
- limits and all ticks can be set freely (e.g. -1 -0.2 -0.001 0 0.3 5)
- colorbar sections should have equal length (i.e. same distance between all tick marks)
Ideally, I'd like to define the colors myself, e.g. like so:
if -3< value <= -2, color=[0.8 0 0]
if -2< value < -1.8, color=[0.6 0 0]
.. if value == -999, color=[0.3 0.3 0.3]
if isnan(value), color=[1 1 1]
0 个评论
回答(1 个)
Star Strider
2014-9-19
Note that ‘NaN’ values will not plot (at least they do not in my experience), so you will have to replace them with some defined quantity, and account for that in your colormap and colorbar.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!