bar3h
Plot a horizontal 3D bar graph.
bar3h (y)
plots 3D bar graph for the elements of y. Each
bar corresponds to an element in y, which can be a scalar, vector, or
2D matrix. By default, each column in y is considered as a series and
it is handled as a distinct series of bars. When y is a vector, unlike
MATLAB, which plots it as a single series of bars, Octave discriminates
between a row and column vector of y. Hence, when y is column
vector, it is plotted as a single series of bars (same color), whereas when
y 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 z-axis
ranging from to and each
column on the x-axis
ranging from to .
bar3h (z, y)
plots a 3D bar graph of the elements in
y at the z-values
specified in z. It should be noted
that z only affects the tick names along the z-axis
rather the
actual values. If you want to specify non-numerical values for z, you
can specify it with the paired name/value syntax shown below.
bar3h (…, width)
sets the width of the bars along the
x-
and z-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.
bar3h (…, style)
specifies the style of the bars, where
style can be 'detached'
, 'grouped'
, or
'stacked'
. The default style is @code {’detached’.
bar3h (…, 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 y, then each inidividual bar is assigned the particular
color. You can also define color using the paired
name/value syntax shown below.
bar3h (…, 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 z-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 . | |
"zlabel" | A cellstr vector specifying the names of the
bars in the same series along the z-axis . |
bar3h (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 = bar3h (…)
returns a patch handle p, which can be
used to set properties of the bars after displaying the 3D bar graph.
Source Code: bar3h
## Ploting 5 bars in the same series. y = [50; 40; 30; 20; 10]; bar3h (y); |
## Ploting 5 bars in different groups. y = [50, 40, 30, 20, 10]; bar3h (y); |
## A 3D bar graph with each series corresponding to a column in y. y = [1, 4, 7; 2, 5, 8; 3, 6, 9; 4, 7, 10]; bar3h (y); |
## Specify z-axis locations as tick names. z must be a column vector! z = [1950, 1960, 1970, 1980, 1990]'; y = [16, 8, 4, 2, 1]'; bar3h (z, y); |
## Plot 3 series as a grouped plot without any space between the grouped bars y = [70 50 33 10; 75 55 35 15; 80 60 40 20]; bar3h (y, 1, 'grouped'); |
## Plot a stacked style 3D bar graph y = [19, 30, 21, 30; 40, 16, 32, 12]; b = bar3h (y, 0.5, 'stacked'); |