Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Angela
Angela el 19 de Sept. de 2014
Respondida: Star Strider el 19 de Sept. de 2014
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]

Respuestas (1)

Star Strider
Star Strider el 19 de Sept. de 2014
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.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by