colorbar
Adds a color bar that shows how data values map to colors.
Category: Graphics > Formatting and Annotation
Syntax
colorbar
Adds a color bar at the right of the axes.
colorbar(location)
Places it at 'eastoutside', 'southoutside' and similar positions.
colorbar('off')
Removes the color bar.
Description
The bar shows the current colormap over the color limits of the axes (see clim), so a reader can convert colors back into values. Use it with imagesc, surf, contourf and other plots that color by data.
Input arguments
location- Position name, such as
'north','south','east','west'with an optional'outside'suffix.
Output arguments
c- Handle of the color bar.
Example
Color bar beside an image
imagesc(magic(4))
colorbar
In the app, the figure is drawn below the code.
Notes
The returned handle is an axes object, so Colorbar-specific properties such as Label or Location are not available through it.