This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Change Fill Colors for Contour Plot

This example shows how to change the colors used in a filled contour plot.

Change Colormap

Set the colors for the filled contour plot by changing the colormap. Pass the predefined colormap name, hot, to the colormap function.

[X,Y,Z] = peaks;
figure
contourf(X,Y,Z,20)
colormap(hot)
title('Hot Colormap')

Control Mapping of Data Values to Colormap

Use only the colors in the center of the hot colormap by setting the color axis scaling to a range much larger than the range of values in matrix Z. The caxis function controls the mapping of data values into the colormap. Use this function to set the color axis scaling.

caxis([-20,20])
title('Center of Hot Colormap')

See Also

| |