Documentation Center

  • Trial Software
  • Product Updates

colormapeditor

Open colormap editor

Syntax

colormapeditor

Description

colormapeditor displays the current figure's colormap as a strip of rectangular cells in the colormap editor. Node pointers are colored cells below the colormap strip that indicate points in the colormap where the rate of the variation of R, G, and B values changes. You can also work in the HSV colorspace by setting the Interpolating Colorspace selector to HSV.

You can also start the colormap editor by selecting Colormap from the Edit menu.

Node Pointer Operations

You can select and move node pointers to change a range of colors in the colormap. The color of a node pointer remains constant as you move it, but the colormap changes by linearly interpolating the RGB values between nodes.

Change the color at a node by double-clicking the node pointer. A color picker box appears, from which you can select a new color. After you select a new color at a node, the colors between nodes are reinterpolated.

You can select a different color map using the Standard Colormaps submenu of the GUI Tools menu. The Plotting Tools Property Editor has a dropdown menu that also lets you select from standard colormaps, but does not help you to modify a colormap.

Operation

How to Perform

Select a built-in colormap

Tools > Standard Colormaps

Add a node

Click below the corresponding cell in the colormap strip.

Select a node

Left-click the node.

Select multiple nodes

Adjacent: left-click first node, Shift+click the last node.

Nonadjacent: left-click first node, Ctrl+click subsequent nodes.

Move a node

Select and drag with the mouse or select and use the left and right arrow keys.

Move multiple nodes

Select multiple nodes and use the left and right arrow keys to move nodes as a group. Movement stops when one of the selected nodes hits an unselected node or an end node.

Delete a node

Select the node and then press the Delete key, or select Delete from the Edit menu, or type Ctrl+x.

Delete multiple nodes

Select the nodes and then press the Delete key, or select Delete from the Edit menu, or type Ctrl+x.

Display color picker for a node

Double-click the node pointer.

Current Color Info

When you put the mouse over a color cell or node pointer, the colormap editor displays the following information about that colormap element:

  • The element's index in the colormap

  • The value from the graphics object color data that is mapped to the node's color (i.e., data from the CData property of any image, patch, or surface objects in the figure)

  • The color's RGB and HSV color value

Interpolating Colorspace

The colorspace determines what values are used to calculate the colors of cells between nodes. For example, in the RGB colorspace, internode colors are calculated by linearly interpolating the red, green, and blue intensity values from one node to the next. Switching to the HSV colorspace causes the colormap editor to recalculate the colors between nodes using the hue, saturation, and value components of the color definition.

Note that when you switch from one colorspace to another, the color editor preserves the number, color, and location of the node pointers, which can cause the colormap to change.

Interpolating in HSV.  Since hue is conceptually mapped about a color circle, the interpolation between hue values can be ambiguous. To minimize this ambiguity, the interpolation uses the shortest distance around the circle. For example, interpolating between two nodes, one with hue of 2 (slightly orange red) and another with a hue of 356 (slightly magenta red), does not result in hues 3,4,5...353,354,355 (orange/red-yellow-green-cyan-blue-magenta/red). Taking the shortest distance around the circle gives 357,358,1,2 (orange/red-red-magenta/red).

Color Data Min and Max

The Color Data Min and Color Data Max text fields enable you to specify values for the axes CLim property. These values change the mapping of object color data (the CData property of images, patches, and surfaces) to the colormap. See Axes Color Limits — the CLim Property for discussion and examples of how to use this property.

Examples

This example modifies a default MATLAB® colormap so that ranges of data values are displayed in specific ranges of color. The graph is a slice plane illustrating a cross section of fluid flow through a jet nozzle. See the slice reference page for more information on this type of graph.

Example Objectives

The objectives are as follows:

  • Regions of flow from left to right (positive data) are mapped to colors from yellow through orange to dark red. Yellow is slowest and dark red is the fastest moving fluid.

  • Regions that have a speed close to zero are colored green.

  • Regions where the fluid is actually moving right to left (negative data) are shades of blue (darker blue is faster).

The following picture shows the desired coloring of the slice plane. The colorbar shows the data to color mapping.

Running the Example

    Note   If you are viewing this documentation in the MATLAB help browser, you can display the graph used in this example by running this filethis file from the MATLAB editor (select Run from the Debug menu).

Initially, the default colormap (jet) colored the slice plane, as illustrated in the following picture. Note that this example uses a colormap that is 48 elements to display wider bands of color (the default is 64 elements).

  1. Start the colormap editor using the colormapeditor command. The color map editor displays the current figure' s colormap, as shown in the following picture.

  2. Since we want the regions of left-to-right flow (positive speed) to range from yellow to dark red, we can delete the cyan node pointer. To do this, first select it by clicking with the left mouse button and press Delete. The colormap now looks like this.

    The Immediate Apply box is checked, so the graph displays the results of the changes made to the colormap.

  3. We want the fluid speed values around zero to stand out, so we need to find the color cell where the negative-to-positive transition occurs. Dragging the cursor over the color strip enables you to read the data values in the Current Color Info panel.

    In this case, cell 10 is the first positive value, so we click below that cell and create a node pointer. Double-clicking the node pointer displays the color picker. Set the color of this node to green.

    The graph continues to update to the modified colormap.

  4. In the current state, the colormap colors are interpolated from the green node to the yellowish node about 20 cells away. We actually want only the single cell that is centered around zero to be colored green. To limit the color green to one cell, move the blue and yellow node pointers next to the green pointer.

  5. Before making further adjustments to the colormap, we need to move the green cell so that it is centered around zero. Use the colorbar to locate the green cell.

    To recenter the green cell around zero, select the blue, green, and yellow node pointers (left-click blue, Shift+click yellow) and move them as a group using the left arrow key. Watch the colorbar in the figure window to see when the green color is centered around zero.

    The slice plane now has the desired range of colors for negative, zero, and positive data.

  6. Increase the orange-red coloring in the slice by moving the red node pointer toward the yellow node.

  7. Darken the endpoints to bring out more detail in the extremes of the data. Double-click the end nodes to display the color picker. Set the red endpoint to the RGB value [50 0 0] and set the blue endpoint to the RGB value [0 0 50].

    The slice plane coloring now matches the example objectives.

Saving the Modified Colormap

You can save the modified colormap using the colormap function or the figure Colormap property.

After you have applied your changes, save the current figure colormap in a variable:

mycmap = get(fig,'Colormap'); 

To use this colormap in another figure, set that figure's Colormap property:

set(new_fig,'Colormap',mycmap)

To save your modified colormap in a MAT-file, use the save command to save the mycmap workspace variable:

save('MyColormaps','mycmap')

To use your saved colormap in another MATLAB session, load the variable into the workspace and assign the colormap to the figure:

load('MyColormaps','mycmap')
set(fig,'Colormap',mycmap)

More About

See Also

| | | | |

Was this topic helpful?