colorbar
R2026bColorbar showing color scale
Syntax
Description
colorbar displays a vertical colorbar to the right of the
current axes or chart. Colorbars display the current colormap and indicate the
mapping of data values into the colormap.
colorbar(___,
modifies the colorbar appearance using one or more name-value arguments. For
example, Name=Value)Direction="reverse" reverses the color scale.
Specify Name=Value as the last arguments in any of the
previous syntaxes. Not all types of charts support modifying the colorbar
appearance.
colorbar(
adds a colorbar to the axes or chart specified by target,___)target.
Specify the target axes or chart as the first argument in any of the previous
syntaxes.
c = colorbar(___) returns the ColorBar object. You can use this object to set
properties after creating the colorbar. Specify the return argument
c with any of the previous syntaxes.
Examples
Input Arguments
Name-Value Arguments
Tips
To add a text description along the colorbar, access the underlying text object using the
Labelproperty of the colorbar.c.Label.String = "My Colorbar Label";To change the label appearance, such as the font style or color, set other text properties. For a list of properties, see Text Properties. For example, this code changes the font size.
c.Label.FontSize = 12;
Adding a colorbar might resize the axes to accommodate the colorbar.
If an axes does not exist, then the
colorbarfunction creates a blank axes and displays a colorbar with the default colormap.You can use
colorbar('delete')orcolorbar('hide')instead ofcolorbar('off')to delete all colorbars in the current axes. All of these commands are equivalent.










