lcolorbar
Color bar with text labels
Description
lcolorbar(
displays a vertical color
bar, with labels specified by the text in labels
)labels
, to the right of the
current axes.
lcolorbar(
specifies options for the color bar using name-value arguments.labels
,Name,Value
)
Examples
Input Arguments
Output Arguments
Limitations
In some cases, such as when adding color bars to subplots or
when changing the colormap of a specified axes, the lcolorbar
function
produces unexpected results. In these cases, create a labeled color bar by using the colorbar
function instead of the lcolorbar
function.
This code shows how to make a labeled color bar with 5 labels by using the
colorbar
function. Within the code:
Create an axes object, change the colormap, and add a color bar
Place a tick mark at the center of each color band
Add the tick labels
ax = axes; n = 5; colormap(ax,jet(n)) cb = colorbar; ticks = linspace(ax.CLim(1),ax.CLim(2),1 + 2*n); ticks(1:2:end) = []; cb.Ticks = ticks; labels = ["apples","oranges","grapes","peaches","melons"]; cb.TickLabels = labels;
Version History
Introduced before R2006a