# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# stem3

Plot 3-D discrete sequence data

## Syntax

• stem3(Z)
example
• stem3(X,Y,Z)
example
• stem3(___,'filled')
example
• stem3(___,LineSpec)
example
• stem3(___,Name,Value)
example
• stem3(ax,___)
example
• h = stem3(___)
example

## Description

example

stem3(Z) plots entries in Z as stems extending from the xy-plane and terminating with circles at the entry values. The stem locations in the xy-plane are automatically generated. 

example

stem3(X,Y,Z) plots entries in Z as stems extending from the xy-plane where X and Y specify the stem locations in the xy-plane. The inputs X, Y, and Z must be vectors or matrices of the same size. 

example

stem3(___,'filled') fills the circles. Use this option with any of the input argument combinations in the previous syntaxes.

example

stem3(___,LineSpec) specifies the line style, marker symbol, and color.

example

stem3(___,Name,Value) specifies stem series properties using one or more Name,Value pair arguments. 

example

stem3(ax,___) plots into the axes specified by ax instead of into the current axes (gca). The option, ax, can precede any of the input argument combinations in the previous syntaxes.

example

h = stem3(___) returns the stem series object h. 

## Examples

collapse all

Create a 3-D stem plot of cosine values between and with a row vector input.

figure X = linspace(-pi/2,pi/2,40); Z = cos(X); stem3(Z) 

stem3 plots elements of Z against the same y value at equally space x values.

Create a 3-D stem plot of cosine values between and with a column vector input.

figure X = linspace(-pi/2,pi/2,40)'; Z = cos(X); stem3(Z) 

stem3 plots elements of Z against the same x value at equally space y values.

Create a 3-D stem plot of sine and cosine values between and with a matrix input.

figure X = linspace(-pi/2,pi/2,40); Z = [sin(X); cos(X)]; stem3(Z) 

stem3 plots each row of Z against the same y value at equally space x values.

Create a 3-D stem plot and specify the stem locations along a curve. Use view 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 and Y determine the stem locations. Z determines the marker heights.

Create a 3-D stem plot with matrix data and specify the stem locations in the xy-plane.

figure [X,Y] = meshgrid(0:.1:1); Z = exp(X+Y); stem3(X,Y,Z) 

X and Y determine the stem locations. Z determines the marker heights.

Create a 3-D stem plot of cosine values between and and fill in the markers.

X = linspace(-pi,pi,40); Z = cos(X); stem3(Z,'filled') 

Create a 3-D stem plot of cosine values between and . 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 three LineSpec 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.

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 and Y determine the stem locations. Z determines the marker heights.

Create a 3-D stem plot of cosine values between and . 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') 

Specify the axes for a 3-D stem plot.

Define vectors X, Y and Z.

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) and s(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) 

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. Use view 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 the set function instead.

h.Color = 'm'; h.MarkerFaceColor = 'y'; view(-10,35) 

## Input Arguments

collapse all

Data sequence to display, specified as a vector or matrix. stem3 plots each element in Z as a stem extending from the xy-plane and terminating at the data value.

• If Z is a row vector, stem3 plots all elements against the same y value at equally spaced x values.

• If Z is a column vector, stem3 plots all elements against the same x value at equally spaced y values.

• If Z is a matrix, stem3 plots each row of Z against the same y value at equally spaced x values.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Locations to plot values ofZ, specified as a vector or a matrix. Inputs X, Y and Z must be vectors or matrices of the same size.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Locations to plot values of Z, specified as a vector or a matrix. Inputs X, Y and Z must be vectors or matrices of the same size.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Line style, marker, and color, specified as a character vector of symbols. For more information, see LineSpec.

Example: ':*r'

Data Types: char

Axes object. If you do not specify an axes, then stem plots into the current axes.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: '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, see Stem Series Properties.

collapse all

Line style, specified as one of the line styles listed in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

Line width of stem and marker edge, specified as a positive value in point units.

Example: 0.75

Stem color, specified as an RGB triplet, a character vector of a color name, or 'none'. If you specify the Color as 'none', then the stems are invisible.

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]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: 'blue'

Example: [0 0 1]

Marker symbol, specified as one of the markers listed in this table.

ValueDescription
'o'Circle
'+'Plus sign
'*'Asterisk
'.'Point
'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'

Marker size, specified as a positive value in points.

Example: 10

Marker outline color, specified as one of these values:

• 'auto' — Use the same color specified in the Color property.

• 'none' — Use no color, which makes unfilled markers invisible.

• RGB triplet or character vector of a color name — Use the specified color.

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]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: [0.5 0.5 0.5]

Example: 'blue'

Marker fill color, specified as one of these values:

• 'none' — Use no color, which makes the interior invisible.

• 'auto' — Use the same color as the Color property for the axes.

• RGB triplet or character vector of a color name — Use the specified color.

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]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: [0.3 0.2 0.1]

Example: 'green'

## Output Arguments

collapse all

Stem series object, specified as a scalar. This is a unique identifier, which you can use to modify the properties of the stem series after it is created.