필터 지우기
필터 지우기

Colorbar and m_contourf.m: Setting user-defined color ranges

조회 수: 2 (최근 30일)
Angela
Angela 2014년 9월 19일
답변: Star Strider 2014년 9월 19일
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]

답변 (1개)

Star Strider
Star Strider 2014년 9월 19일
The colormapeditor might do what you want. Search the File Exchange for colorbar or colormap.
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.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by