barh

Draws a horizontal bar chart.

Category: Graphics > 2-D and 3-D Plots

Syntax

barh(y)

One horizontal bar per element of y, from the bottom up.

barh(x, y)

Places the bars at the vertical positions in x.

b = barh(___, Name, Value)

Sets bar properties and returns the bar objects.

Description

barh is bar with the axes swapped: values run along the horizontal axis and the bar positions along the vertical one. It is handy for long category labels and for ranked lists. A matrix gives grouped bars, as in bar.

Input arguments

x
Increasing positions on the vertical axis.
y
Lengths of the bars: a vector or a matrix.

Output arguments

b
Array of Bar objects, one per column of y.

Example

Ranked values

scores = [62 75 88 54];
barh(1:4, scores, 'FaceColor', [0.2 0.5 0.8])
xlabel('Score')
ylabel('Team')

In the app, the figure is drawn below the code.

See also

bar bar3h histogram plot