Graphics    

Using a Large Number of Colors

Overview

Set MinColormap to a number equal to the size of your colormap when you do not want MATLAB to approximate colors. However, this may cause nonactive windows to display with incorrect colors.

More Details

Problems can arise when you define a large colormap and/or a large number of fixed colors. If the number of color slots required exceeds the number available in the system color table, MATLAB specifies all fixed colors first, then linearly subsamples the colormap to fill the remaining slots.

For example, if the original colormap contains 128 colors and there are only 64 slots available, then MATLAB adds every other color to the color table. MATLAB maps each color in the original colormap to the color in the subsampled colormap that most closely matches the original color.

Specifying the Minimum Colormap Size - MinColormap

The figure MinColormap property specifies the minimum number of slots in the system color table that MATLAB uses for the figure colormap. This enables you to use colormaps of any size up to the value of MinColormap and ensure MATLAB does not subsample the colors.

If you specify a value that is greater than the number of available slots, MATLAB takes over slots used to define system colors (on computers that allow overwriting of these colors). When this happens, nonactive windows can display with incorrect colors because MATLAB changed the color of the slot assigned to their pixels.

MATLAB does not take over color slots allocated to fixed colors. Therefore, limiting the number of fixed colors maximizes the number of colors allocated to the colormap. You can limit the number of fixed colors by specifying all noncolormap object colors (e.g., text, line, and figure colors) as the same color, and setting the axes ColorOrder property to just one color (the default is seven colors).


  Colormap Colors and Fixed Colors Nonactive Figures and Shared Colors