3. Color Map CustomizationΒΆ

Consider the default color scheme produced using a MATLAB contour plot.

>> contourf(peaks(51))
>> colorbar
>> set_plot
_images/peaks-jet.png

This is called the 'jet' color scheme, and it is widely recognized. However, it is often desirable to use a different color scheme. A simple example is to reverse the color scheme, which can be done with a single command.

>> set_colormap reverse-jet
_images/peaks-reverse.png

Often it’s appropriate to use a monochrome color scheme if the figure will be published in black and white.

>> set_colormap('Blue')
_images/peaks-blue.png

Monochrome color maps are extremely easy to make with set_colormap(). Any single color will produce a map ranging from white to that color, with the exception of the colors 'Red', 'Yellow', 'Green', 'Cyan', 'Blue', 'Magenta', and 'Black', which have more highly customized sequences of colors. The following example shows how to construct a color map using only one color specification.

>> set_colormap('DarkSalmon')
_images/peaks-mono.png

This is always equivalent to manually specifying white and then the color, and serves as a minor shortcut. In other words, the above is the same as

>> set_colormap({'w', 'DarkSalmon'})

It’s possible to construct a map out of any number of colors. For example, a bichromic scale is often useful for highlighting negative and positive regions of a contour plot.

>> set_colormap({[0.7,0.2,0.1], 'w', 'DarkTurquoise'})
_images/peaks-bi.png

Since the peaks data set has different minimum and maximum values, the preceding example did not actually line up the white with zero. To fix that, you have to determine where zero is on the current color axis.

>> v = caxis;
>> t = -v(1) / (v(2) - v(1));
>> set_colormap({0, 'DarkOrange'; t, 'w'; 1, 'Indigo'})
_images/peaks-fix.png

By putting white twice in a row in the color map description, it is possible to highlight certain regions even more. For example, this only fills in the contours for positive values.

>> set_colormap({0, 'w'; t, 'w'; 1, 'Teal'})
_images/peaks-dead.png

Previous topic

2.4.2. Cascading Style Chart

Next topic

4. Color Conversion Tools

This Page