stem3
图3 d离散序列数据
Syntax
stem3(Z)
stem3(X,Y,Z)
stem3(___,'filled')
stem3(___,LineSpec)
stem3(___,Name,Value)
stem3(ax,___)
h = stem3(___)
Description
stem3(
plots entries inZ
)Z
as stems extending from thexy-plane and terminating with circles at the entry values. The stem locations in thexy-plane are automatically generated.
stem3(___,
fills the circles. Use this option with any of the input argument combinations in the previous syntaxes.'filled'
)
stem3(___,
modifies the stem chart using one or more name-value pair arguments.Name,Value
)
Examples
Row Vector Input
Create a 3-D stem plot of cosine values betweenandwith a row vector input.
figure X = linspace(-pi/2,pi/2,40); Z = cos(X); stem3(Z)
stem3
plots elements ofZ
against the sameyvalue at equally spacexvalues.
Column Vector Input
Create a 3-D stem plot of cosine values betweenandwith a column vector input.
figure X = linspace(-pi/2,pi/2,40)'; Z = cos(X); stem3(Z)
stem3
plots elements ofZ
against the samexvalue at equally spaceyvalues.
Matrix Input
Create a 3-D stem plot of sine and cosine values betweenandwith a matrix input.
figure X = linspace(-pi/2,pi/2,40); Z = [sin(X); cos(X)]; stem3(Z)
stem3
plots each row ofZ
against the sameyvalue at equally spacexvalues.
Specify Stem Locations with Vector Inputs
Create a 3-D stem plot and specify the stem locations along a curve. Useview
to adjust the angle of the axes in the figure.
figure X = linspace(-5,5,60); Y = cos(X); Z = X.^2; stem3(X,Y,Z) view(-8,30)
X
andY
determine the stem locations.Z
determines the marker heights.
Specify Stem Locations with Matrix Inputs
Create a 3-D stem plot with matrix data and specify the stem locations in thexy-plane.
figure [X,Y] = meshgrid(0:.1:1); Z = exp(X+Y); stem3(X,Y,Z)
X
andY
determine the stem locations.Z
determines the marker heights.
Fill in Markers
Create a 3-D stem plot of cosine values betweenandand fill in the markers.
X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'filled')
Line Style, Marker Symbol, and Color Options
Create a 3-D stem plot of cosine values betweenand. Use a dashed line style for the stem, set the marker symbols to stars, and set the color to magenta.
figure X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'--*m')
To specify only two of the threeLineSpec
options, omit the third option from the character vector. For example,'*m'
sets the marker symbol and the color and uses the default line style.
Line Style, Marker Symbol, and Color Options
Create a 3-D stem plot and specify the stem locations along a circle. Set the stem to a dotted line style, the marker symbols to stars, and the color to magenta.
figure theta = linspace(0,2*pi); X = cos(theta); Y = sin(theta); Z = theta; stem3(X,Y,Z,':*m')
X
andY
determine the stem locations.Z
determines the marker heights.
Additional Style Options
Create a 3-D stem plot of cosine values betweenand. Set the marker symbols to squares with green faces and magenta edges.
figure X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'Marker','s',...'MarkerEdgeColor','m',...'MarkerFaceColor','g')
Axes Handles
Specify the axes for a 3-D stem plot.
Define vectorsX
,Y
andZ
.
X = linspace(-2,2,50); Y = X.^3; Z = exp(X);
Create a figure with two subplots and return the handles to each axes,s(1)
ands(2)
. Plot a 3-D stem plot in the lower subplot by referring to its axes handle,s(2)
. For comparison, plot a 2-D stem plot in the upper subplot by referring to its axes handle,s(1)
.
figure s(1) = subplot(2,1,1); s(2) = subplot(2,1,2); stem(s(1),X,Z) stem3(s(2),X,Y,Z)
Modify Stem Series After Creation
Create a 3-D stem plot and return the stem series object.
X = linspace(0,2); Y = X.^3; Z = exp(X).*cos(Y); h = stem3(X,Y,Z,'filled');
Change the color to magenta and set the marker face color to yellow. Useview
to adjust the angle of the axes in the figure. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use theset
function instead.
h.Color ='m'; h.MarkerFaceColor ='y'; view(-10,35)
Input Arguments
Z
—Data sequence to display
vector or matrix
Data sequence to display, specified as a vector or matrix.stem3
plots each element inZ
as a stem extending from thexy-plane and terminating at the data value.
If
Z
is a row vector,stem3
plots all elements against the sameyvalue at equally spacedxvalues.If
Z
is a column vector,stem3
plots all elements against the samexvalue at equally spacedyvalues.If
Z
is a matrix,stem3
plots each row ofZ
against the sameyvalue at equally spacedxvalues.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
|logical
X
—Locations to plot values ofZ
vector or matrix
Locations to plot values ofZ
, specified as a vector or a matrix. InputsX
,Y
andZ
must be vectors or matrices of the same size.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
|logical
Y
—Locations to plot values ofZ
vector or matrix
Locations to plot values ofZ
, specified as a vector or a matrix. InputsX
,Y
andZ
must be vectors or matrices of the same size.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
|logical
LineSpec
—Line style, marker, and color
character vector|string
Line style, marker, and color, specified as a character vector or string. For more information, seeLineSpec
.
Example:':*r'
Data Types:char
ax
—Axes
object
Axes
object
Axes
object. If you do not specify the axes, thenstem
plots into the current axes.
Name-Value Pair Arguments
Specify optional comma-separated pairs ofName,Value
arguments.Name
is the argument name andValue
is the corresponding value.Name
must appear inside single quotes (' '
). You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN
.
'LineStyle',':','MarkerFaceColor','red'
plots the stem as a dotted line and sets the marker face color to red.
The properties listed here are only a subset. For a complete list, seeStem Properties.
'LineStyle'
—Line style
“- - -”
(default) |'--'
|':'
|'-.'
|'none'
Line style, specified as one of the line styles listed in this table.
Line Style | Description | Resulting Line |
---|---|---|
“- - -” |
Solid line |
|
'--' |
Dashed line |
|
':' |
Dotted line |
|
'-.' |
Dash-dotted line |
|
'none' |
No line | No line |
'LineWidth'
—Line width of stem and marker edge
0.5
(default) |positive value
Line width of stem and marker edge, specified as a positive value in point units.
Example:0.75
'Color'
—Stem color
[0 0 0]
(default) |RGB triplet|'r'
|'g'
|'b'
| ...
Stem color, specified as an RGB triplet or one of the color options listed in the table.
For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1]
; for example,[0.4 0.6 0.7]
. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.
Option | Description | Equivalent RGB Triplet |
---|---|---|
'red' or'r' |
Red | [1 0 0] |
'green' or'g' |
Green | [0 1 0] |
'blue' or'b' |
Blue | [0 0 1] |
'yellow' or'y' |
Yellow | [1 1 0] |
'magenta' or'm' |
Magenta | [1 0 1] |
'cyan' or'c' |
Cyan | [0 1 1] |
'white' or'w' |
White | [1 1 1] |
'black' or'k' |
Black | [0 0 0] |
'none' |
No color | Not applicable |
Example:'blue'
Example:[0 0 1]
'Marker'
—Marker symbol
'o'
(default) |'+'
|'*'
|'.'
|'x'
| ...
Marker symbol, specified as one of the markers listed in this table.
Value | Description |
---|---|
'o' |
Circle |
'+' |
Plus sign |
'*' |
Asterisk |
'.' |
点 |
'x' |
Cross |
'square' or's' |
Square |
'diamond' or'd' |
Diamond |
“^” |
Upward-pointing triangle |
'v' |
Downward-pointing triangle |
'>' |
Right-pointing triangle |
'<' |
Left-pointing triangle |
'pentagram' or'p' |
Five-pointed star (pentagram) |
'hexagram' or'h' |
Six-pointed star (hexagram) |
'none' |
No markers |
Example:'+'
Example:'diamond'
'MarkerSize'
—Marker size
6
(default) |positive value
Marker size, specified as a positive value in points.
Example:10
'MarkerEdgeColor'
—Marker outline color
'auto'
(default) |RGB triplet|'r'
|'g'
|'b'
| ...
Marker outline color, specified as'auto'
, an RGB triplet, or one of the color options listed in the table. The default value of'auto'
uses the same color as theColor
property.
For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1]
; for example,[0.4 0.6 0.7]
. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.
Option | Description | Equivalent RGB Triplet |
---|---|---|
'red' or'r' |
Red | [1 0 0] |
'green' or'g' |
Green | [0 1 0] |
'blue' or'b' |
Blue | [0 0 1] |
'yellow' or'y' |
Yellow | [1 1 0] |
'magenta' or'm' |
Magenta | [1 0 1] |
'cyan' or'c' |
Cyan | [0 1 1] |
'white' or'w' |
White | [1 1 1] |
'black' or'k' |
Black | [0 0 0] |
'none' |
No color | Not applicable |
Example:[0.5 0.5 0.5]
Example:'blue'
'MarkerFaceColor'
—Marker fill color
'none'
(default) |'auto'
|RGB triplet|'r'
|'g'
|'b'
| ...
Marker fill color, specified as'auto'
, an RGB triplet, or one of the color options listed in the table. The'auto'
value uses the same color as theColor
property for the axes.
For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1]
; for example,[0.4 0.6 0.7]
. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.
Option | Description | Equivalent RGB Triplet |
---|---|---|
'red' or'r' |
Red | [1 0 0] |
'green' or'g' |
Green | [0 1 0] |
'blue' or'b' |
Blue | [0 0 1] |
'yellow' or'y' |
Yellow | [1 1 0] |
'magenta' or'm' |
Magenta | [1 0 1] |
'cyan' or'c' |
Cyan | [0 1 1] |
'white' or'w' |
White | [1 1 1] |
'black' or'k' |
Black | [0 0 0] |
'none' |
No color | Not applicable |
Example:(0.3 0.2 0.1)
Example:'green'
Output Arguments
h
—Stem
object
Stem
Stem
object. This is a unique identifier, which you can use to modify the properties of theStem
object after it is created.
See Also
Functions
Properties
Topics
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(西班牙语)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(西班牙语)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)