The Wayback Machine - https://web.archive.org/web/20111014034251/http://www.mathworks.com:80/help/techdoc/creating_plots/f5-41276.html
Skip to Main Content Skip to Search
Product Documentation

Figure Colormaps — The Colormap Property

Introduction

The MATLAB software defines a colormap as a three-column array. Each row of the array defines a particular color by giving three values in the range [0...1]. These values specify the RGB values; the intensity of the red, green, and blue video components.

Colormaps enable you to control how MATLAB maps data values to colors in surfaces, patches, images, and plotting functions that are based on these objects. See the following sections for more information.

Specifying the Figure Colormap

The figure Colormap property contains the colormap array. You can specify the figure colormap by setting this property to an m-by-3 array, where m is the number of colors in the colormap.

For example, the following statement creates a figure with a colormap having 128 random colors.

figure('Colormap',rand(128,3));

The colormap function is an easy way to specify the colormap. MATLAB also provides a number of functions that generate colormaps. For example,

colormap(hsv(96))

sets the colormap of the current figure to a 96 element version of the hsv colormap. See the colormap reference page for a list of predefined colormaps. The default colormap is jet(64).

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A; sessions led by MATLAB experts.

 © 1984-2011- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS