Plot a 2-D stem graph.
If only one argument is given, it is taken as the y-values and the x-coordinates are taken from the indices of the elements.
If y is a matrix, then each column of the matrix is plotted as a separate stem graph. In this case x can either be a vector, the same length as the number of rows in y, or it can be a matrix of the same size as y.
The default color is "b"
(blue), the default line style is
"-"
, and the default marker is "o"
. The line style can
be altered by the linespec
argument in the same manner as the
plot
command. If the "filled"
argument is present the
markers at the top of the stems will be filled in. For example,
x = 1:10; y = 2*x; stem (x, y, "r");
plots 10 stems with heights from 2 to 20 in red;
Optional property/value pairs may be specified to control the appearance of the plot.
If the first argument hax is an axes handle, then plot into this axis,
rather than the current axes returned by gca
.
The optional return value h is a handle to a "stem series" hggroup. The single hggroup handle has all of the graphical elements comprising the plot as its children; This allows the properties of multiple graphics objects to be changed by modifying just a single property of the "stem series" hggroup.
For example,
x = [0:10]'; y = [sin(x), cos(x)] h = stem (x, y); set (h(2), "color", "g"); set (h(1), "basevalue", -1)
changes the color of the second "stem series" and moves the base line of the first.
Stem Series Properties
The linestyle of the stem. (Default: "-"
)
The width of the stem. (Default: 0.5)
The color of the stem, and if not separately specified, the marker.
(Default: "b"
[blue])
The marker symbol to use at the top of each stem. (Default: "o"
)
The edge color of the marker. (Default: "color"
property)
The color to use for "filling" the marker.
(Default: "none"
[unfilled])
The size of the marker. (Default: 6)
The handle of the line object which implements the baseline. Use set
with the returned handle to change graphic properties of the baseline.
The y-value where the baseline is drawn. (Default: 0)
See also: stem3, bar, hist, plot, stairs.
The following code
clf; y = 1:10; stem (y); title ("stem plot of y-values only");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; stem (x, y); title ("stem plot of x and y-values");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; h = stem (x, y, "r"); title ("stem plot with modified color");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; h = stem (x, y, "-.k"); title ("stem plot with modified line style and color");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; h = stem (x, y, "-.ks"); title ("stem plot with modified line style, color, and marker");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; h = stem (x, y, "filled"); title ('stem plot with "filled" markers');
Produces the following figure
Figure 1 |
---|
The following code
clf; x = 1:10; y = 2*x; h = stem (x, y, "markerfacecolor", [1 0 1]); title ("stem plot modified with property/value pair");
Produces the following figure
Figure 1 |
---|
The following code
clf; x = (0 : 10)'; y = [sin(x), cos(x)]; h = stem (x, y); set (h(2), "color", "g"); set (h(1), "basevalue", -0.75); title ("stem plots modified through hggroup handle");
Produces the following figure
Figure 1 |
---|
The following code
clf; N = 11; x = 0:(N-1); y = rand (1, N); hs = stem (x(1), y(1)); set (gca (), "xlim", [1, N-1], "ylim", [0, 1]); title ("stem plot data modified through hggroup handle"); for k=2:N set (hs, "xdata", x(1:k), "ydata", y(1:k)); drawnow (); pause (0.2); endfor
Produces the following figure
Figure 1 |
---|
Package: octave