stem

Plots discrete data as vertical stems ending in markers.

Category: Graphics > 2-D and 3-D Plots

Syntax

stem(Y)

Draws a stem for each value of Y at its index.

stem(X, Y)

Draws stems at the positions in X.

stem(___, 'filled')

Fills the markers.

h = stem(___)

Also returns the stem handles.

Description

A stem plot suits sequences that only exist at integer points, such as the samples of a discrete-time signal or an impulse response. Each stem runs from the baseline at zero up to the data value.

Input arguments

X, Y
Vectors of the same length. A matrix Y draws one series per column.
LineSpec
Optional string with line style, marker and color.

Output arguments

h
Handles of the stem series.

Example

Squares of 1 to 8

stem(1:8, (1:8).^2, 'filled')
grid on

In the app, the figure is drawn below the code.

See also

stem3 stairs plot bar