| Contents | Index |
![]()
To graph selected variables, use the Plot Selector
in the Workspace Browser,
or use the Figure Palette Plot Catalog. Manipulate graphs in plot
edit mode with the Property Editor. For details, see Plotting Tools
— Interactive Plotting in the MATLAB Graphics
documentation and Creating Graphics
from the Workspace Browser in the MATLAB Desktop Tools
documentation.
stem(Y)
stem(X,Y)
stem(...,'fill')
stem(...,LineSpec)
stem(...,'PropertyName',PropertyValue,...)
stem(axes_handle,...)
h = stem(...)
A two-dimensional stem plot displays data as lines extending from a baseline along the x-axis. A circle (the default) or other marker whose y-position represents the data value terminates each stem.
stem(Y) plots the data sequence Y as stems that extend from equally spaced and automatically generated values along the x-axis. When Y is a matrix, stem plots all elements in a row against the same x value.
stem(X,Y) plots X versus the columns of Y. X and Y must be vectors or matrices of the same size. Additionally, X can be a row or a column vector and Y a matrix with length(X) rows.
stem(...,'fill') specifies whether to color the circle at the end of the stem.
stem(...,LineSpec) specifies the line style, marker symbol, and color for the stem and top marker (the baseline is not affected). See LineSpec for more information.
stem(...,'PropertyName',PropertyValue,...) specifies property name and property value pairs for the stemseries objects the function creates.
stem(axes_handle,...) plots into the axes object with the handle axes_handle instead of into the current axes object (gca).
h = stem(...) returns a vector of stemseries object handles in h, one handle per column of data in Y.
This example creates a stem plot representing the cosine of 10 values linearly spaced between 0 and 2π. Note that the line style of the baseline is set by first getting its handle from the stemseries object's BaseLine property.
figure t = linspace(-2*pi,2*pi,10); h = stem(t,cos(t),'fill','--'); set(get(h,'BaseLine'),'LineStyle',':') set(h,'MarkerFaceColor','red')

If you do not want the baseline to show, you can make the baseline invisible:
set(get(h,'Baseline'),'Visble','off')
where h is the stemseries handle returned by the stem function.
Delete the baseline with this command:
delete(get(h,'Baseline'))
Use similar code to change the color or style of the baseline, specifying any line property and value, for example,
set(get(h,'Baseline'),'LineWidth',3)
This example creates a stem plot from a two-column matrix. In this case, the stem function creates two stemseries objects, one for each column of data. Both objects' handles are returned in the output argument h.
h(1) is the handle to the stemseries object plotting the expression exp(-.07*x).*cos(x).
h(2) is the handle to the stemseries object plotting the expression exp(.05*x).*cos(x).
figure x = 0:25; y = [exp(-.07*x).*cos(x);exp(.05*x).*cos(x)]'; h = stem(x,y); set(h(1),'MarkerFaceColor','blue') set(h(2),'MarkerFaceColor','red','Marker','square')

bar | plot | stairs | Stemseries Properties

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |