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!