Main Content

lcolorbar

Colorbar with text labels

Syntax

lcolorbar(labels)
lcolorbar(labels,'property',value,...)
hcb = lcolorbar(...)

Description

lcolorbar(labels) appends text labels to a colorbar at the center of each color band. The labels input argument is specified as a string array or cell array of character vectors. The number of elements in labels must match the length of the colormap.

lcolorbar(labels,'property',value,...) controls the properties of the colorbar.

PropertyDescription
LocationControls the location of the colorbar. Valid values are 'vertical' (the default) or 'horizontal'.
TitleStringText of title.
XLabelStringText of x-label.
YLabelStringText of y-label.
ZLabelStringText of z-label.
ColorAlignmentControls whether the colorbar labels are centered on the color bands or the color breaks. Valid values are 'center' and 'ends'.

Other valid property-value pairs are any properties and values that can be applied to the title and labels of the colorbar axes.

hcb = lcolorbar(...) returns a handle to the colorbar axes.

Examples

figure; colormap(jet(5))
labels = {'apples','oranges','grapes','peaches','melons'};
lcolorbar(labels,'fontweight','bold');