Saturday, July 25, 2009

colorbar

Display colorbar showing the color scale

Syntax

*

colorbar
colorbar('vert')
colorbar('horiz')
colorbar(h)
h = colorbar(...)
colorbar(...,'peer',axes_handle)

Description


The colorbar function displays the current colormap in the current figure and resizes the current axes to accommodate the colorbar.

colorbar updates the most recently created colorbar or, when the current axes does not have a colorbar, colorbar adds a new vertical colorbar.

colorbar('vert') adds a vertical colorbar to the current axes.

colorbar('horiz') adds a horizontal colorbar to the current axes.

colorbar(h) uses the axes h to create the colorbar. The colorbar is horizontal if the width of the axes is greater than its height, as determined by the axes Position property.

h = colorbar(...) returns a handle to the colorbar, which is an axes graphics object.

colorbar(...,'peer',axes_handle) creates a colorbar associated with the axes axes_handle instead of the current axes.

Remarks


colorbar works with two-dimensional and three-dimensional plots.



colordef

Sets default property values to display different color schemes

Syntax


*

colordef white
colordef black
colordef none
colordef(fig,color_option)
h = colordef('new',color_option)

Description

colordef enables you to select either a white or black background for graphics display. It sets axis lines and labels to show up against the background color.

colordef white sets the axis background color to white, the axis lines and labels to black, and the figure background color to light gray.

colordef black sets the axis background color to black, the axis lines and labels to white, and the figure background color to dark gray.

colordef none sets the figure coloring to that used by MATLAB Version 4 (essentially a black background).

colordef(fig,color_option) sets the color scheme of the figure identified by the handle fig to the color option 'white', 'black', or 'none'.

h = colordef('new',color_option) returns the handle to a new figure created with the specified color options (i.e., 'white', 'black', or 'none').

Remarks


colordef affects only subsequently drawn figures, not those currently on the display. This is because colordef works by setting default property values (on the root or figure level). You can list the currently set default values on the root level with the statement:

*

get(0,'defaults')

You can remove all default values using the reset command:

*

reset(0)



colormap

Set and get the current colormap

Syntax


*

colormap(map)
colormap('default')
cmap = colormap

Description

A colormap is an m-by-3 matrix of real numbers between 0.0 and 1.0. Each row is an RGB vector that defines one color. The kth row of the colormap defines the k-th color, where map(k,:) = [r(k) g(k) b(k)]) specifies the intensity of red, green, and blue.

colormap(map) sets the colormap to the matrix map. If any values in map are outside the interval [0 1], MATLAB returns the error: Colormap must have values in [0,1].

colormap('default') sets the current colormap to the default colormap.

cmap = colormap; retrieves the current colormap. The values returned are in the interval [0 1].

Specifying Colormaps

M-files in the color directory generate a number of colormaps. Each M-file accepts the colormap size as an argument. For example,

*

colormap(hsv(128))

creates an hsv colormap with 128 colors. If you do not specify a size, MATLAB creates a colormap the same size as the current colormap.

Supported Colormaps

MATLAB supports a number of colormaps.

* autumn varies smoothly from red, through orange, to yellow.
* bone is a grayscale colormap with a higher value for the blue component. This colormap is useful for adding an "electronic" look to grayscale images.
* colorcube contains as many regularly spaced colors in RGB colorspace as possible, while attempting to provide more steps of gray, pure red, pure green, and pure blue.
* cool consists of colors that are shades of cyan and magenta. It varies smoothly from cyan to magenta.
* copper varies smoothly from black to bright copper.
* flag consists of the colors red, white, blue, and black. This colormap completely changes color with each index increment.
* gray returns a linear grayscale colormap.
* hot varies smoothly from black, through shades of red, orange, and yellow, to white.
* hsv varies the hue component of the hue-saturation-value color model. The colors begin with red, pass through yellow, green, cyan, blue, magenta, and return to red. The colormap is particularly appropriate for displaying periodic functions. hsv(m) is the same as hsv2rgb([h ones(m,2)]) where h is the linear ramp, h = (0:m-1)'/m.
* jet ranges from blue to red, and passes through the colors cyan, yellow, and orange. It is a variation of the hsv colormap. The jet colormap is associated with an astrophysical fluid jet simulation from the National Center for Supercomputer Applications. See the "Examples" section.
* lines produces a colormap of colors specified by the axes ColorOrder property and a shade of gray.
* pink contains pastel shades of pink. The pink colormap provides sepia tone colorization of grayscale photographs.
* prism repeats the six colors red, orange, yellow, green, blue, and violet.
* spring consists of colors that are shades of magenta and yellow.
* summer consists of colors that are shades of green and yellow.
* white is an all white monochrome colormap.
* winter consists of colors that are shades of blue and green.




colormapeditor

Start 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 change. 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. MATLAB displays a color picker from which you can select a new color. After you select a new color at a node, MATLAB reinterpolates the colors in between nodes.

Operation
How to Perform
Add a node
Click below the corresponding cell in the colormap strip
Select a node
Left-click on the node
Select multiple nodes
Adjacent: left-click on first node, Shift+click on the last node
Nonadjacent: left-click on first node, Ctrl+click on 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 on 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 at 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.

No comments:

Post a Comment