bar3
Plot a 3D bar graph.
bar3 (z)
plots 3D bar graph for the elements of z. Each
bar corresponds to an element in z, which can be a scalar, vector, or
2D matrix. By default, each column in z is considered as a series and
it is handled as a distinct series of bars. When z is a vector, unlike
MATLAB, which plots it as a single series of bars, Octave discriminates
between a row and column vector of z. Hence, when z is column
vector, it is plotted as a single series of bars (same color), whereas when
z is row vector, each bar is plotted as a different group (different
colors). For an matrix, the function plots the bars corresponding
to each row on the y-axis
ranging from to and each
column on the x-axis
ranging from to .
bar3 (y, z)
plots a 3D bar graph of the elements in
z at the y-values
specified in y. It should be noted
that y only affects the tick names along the y-axis
rather the
actual values. If you want to specify non-numerical values for y, you
can specify it with the paired name/value syntax shown below.
bar3 (…, width)
sets the width of the bars along the
x-
and y-axes
and controls the separation of bars among each
other. width can take any value in the range . By default,
width is 0.8 and the bars have a small separation. If width is 1, the
bars touch one another. Alternatively, you can define width as a two-
element vector using the paired name/value syntax shown below, in
which case you can control the bar separation along each axis independently.
bar3 (…, style)
specifies the style of the bars, where
style can be 'detached'
, 'grouped'
, or
'stacked'
. The default style is @code {’detached’.
bar3 (…, color
displays all bars using the color specified
by color. For example, use 'red'
or 'red'
to specify all red
bars. When you want to specify colors for several groups, color can be
a cellstr vector with each element specifying the color of each group.
color can also be specified as a numerical matrix, where
each row corresponds to a RGB value with its elements in the range
. If only one color is specified, then it applies to all bars.
If the number of colors equals the number of groups, then each color is
applied to each group. If the number of colors equals the number of elements
in z, then each inidividual bar is assigned the particular color. You
can also define color using the paired name/value syntax
shown below.
bar3 (…, name, value)
specifies one or more of the
following name/value pairs:
Name | Value | |
---|---|---|
"width" | A two-element vector specifying the width if
of the bars along the x- and y-axes , respectively. Each
element must be in the range . | |
"color" | A character or a cellstr vector, or a numerical matrix following the same conventions as the color input argument. | |
"xlabel" | A cellstr vector specifying the group names
along the x-axis . | |
"ylabel" | A cellstr vector specifying the names of the
bars in the same series along the y-axis . |
bar3 (ax, …)
can also take an axes handle ax as a
first argument in which case it plots into the axes specified by ax
instead of into the current axes specified by gca ()
. The optional
argument ax can precede any of the input argument combinations in the
previous syntaxes.
p = bar3 (…)
returns a patch handle p, which can be
used to set properties of the bars after displaying the 3D bar graph.
Source Code: bar3
## Ploting 5 bars in the same series. z = [50; 40; 30; 20; 10]; bar3 (z); |
## Ploting 5 bars in different groups. z = [50, 40, 30, 20, 10]; bar3 (z); |
## A 3D bar graph with each series corresponding to a column in z. z = [1, 4, 7; 2, 5, 8; 3, 6, 9; 4, 7, 10]; bar3 (z); |
## Specify y-axis locations as tick names. y must be a column vector! y = [1950, 1960, 1970, 1980, 1990]'; z = [16, 8, 4, 2, 1]'; bar3 (y, z); |
## Plot 3 series as a grouped plot without any space between the grouped bars z = [70 50 33 10; 75 55 35 15; 80 60 40 20]; bar3 (z, 1, 'grouped'); |
## Plot a stacked style 3D bar graph z = [19, 30, 21, 30; 40, 16, 32, 12]; b = bar3 (z, 0.5, 'stacked'); |