Main Content

Plot 3-D bar graph

`bar3(Z)`

bar3(Y,Z)

bar3(...,width)

bar3(...,style)

bar3(...,color)

bar3(ax,...)

h = bar3(...)

`bar3`

draws a three-dimensional bar graph.

`bar3(Z)`

draws a three-dimensional bar chart, where
each element in `Z`

corresponds to one bar. When `Z`

is a
vector, the *y*-axis scale ranges from `1`

to
`length(Z)`

. When `Z`

is a matrix, the
*y*-axis scale ranges from `1`

to the number of rows in
`Z`

.

`bar3(Y,Z)`

draws a bar chart of the elements in
`Z`

at the locations specified in `Y`

, where
`Y`

is a vector defining the *y* values for the vertical
bars. The *y* values can be nonmonotonic, but cannot contain duplicate
values. If `Z`

is a matrix, elements from the same row in
`Z`

appear at the same location along the `y`

-axis.

`bar3(...,width)`

sets the width of the bars and
controls the separation of bars within a group. The default `width`

is
`0.8`

and the bars have a slight separation. If `width`

is
`1`

, the bars within a group touch one another.

`bar3(...,style)`

specifies the style of the bars.
`style`

is `'detached'`

, `'grouped'`

, or
`'stacked'`

. Default mode of display is
`'detached'`

.

`'detached'`

displays the elements of each row in`Z`

as separate blocks behind one another in the*x*direction.`'grouped'`

displays*n*groups of*m*vertical bars, where*n*is the number of rows and*m*is the number of columns in`Z`

. Each group contains one bar per column in`Z`

.`'stacked'`

displays one bar for each row in`Z`

. The bar height is the sum of the elements in the row. Each bar is multicolored, with colors corresponding to distinct elements and showing the relative contribution each row element makes to the total sum.

`bar3(...,color)`

displays all bars using the color
specified by `color`

. For example, use `'r'`

for red bars.
Specify `color`

as one of these values: `'r'`

,
`'g'`

, `'b'`

, `'c'`

,
`'m'`

, `'y'`

, `'k'`

, or
`'w'`

.

`bar3(ax,...)`

plots into
the axes `ax`

instead of into the current axes (`gca`

).

`h = bar3(...)`

returns a vector of `Surface`

objects. When `Z`

is a matrix,
`bar3`

creates one `Surface`

object per
column in `Z`

.