MATLAB Function Reference Previous page   Next Page

Display colorbar showing the color scale



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(...,'peer',axes_handle) creates a colorbar associated with the axes axes_handle instead of the current axes.

colorbar(axes_handle) adds the colorbar to the axes axes_handle in the default (right) orientation.

colorbar(...,'location') adds a colorbar in the specified orientation with respect to the axes. Possible values for location are

Using one of the ...Outside values for location assure that the colorbar will not overlap the plot, whereas overlaps can occur when you specify any of the other four values.

colorbar(...,'PropertyName',propertyvalue) specifies property names and values for the axes object used to create the colorbar. See axes properties for a description of the properties you can set. The location property applies only to colorbars and legends, not to axes.

cbar_axes = colorbar(...) returns a handle to the colorbar, which is an axes graphics object that contains one additional property, Location.


You can use colorbar with 2-D and 3-D plots.


Display a colorbar beside the axes and use descriptive text strings as y-tick labels.

See Also


Color Operations for related functions

Previous page  colmmd colordef Next page

© 1994-2005 The MathWorks, Inc.