You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Version 2.0.0b1.post7580.dev0+ge487118
matplotlib
Fork me on GitHub

Table Of Contents

This Page

matplotlib.pyplot.stem

matplotlib.pyplot.stem(*args, **kwargs)

Create a stem plot.

A stem plot plots vertical lines at each x location from the baseline to y, and places a marker there.

Call signature:

stem([x,] y, linefmt=None, markerfmt=None, basefmt=None)

The x-positions are optional. The formats may be provided either as positional or as keyword-arguments.

Parameters:

x : array-like, optional

The x-positions of the stems. Default: (0, 1, …, len(y) - 1).

y : array-like

The y-values of the stem heads.

linefmt : str, optional

A string defining the properties of the vertical lines. Usually, this will be a color or a color and a linestyle:

Character Line Style
'-' solid line
'--' dashed line
'-.' dash-dot line
':' dotted line

Default: ‘C0-‘, i.e. solid line with the first color of the color cycle.

Note: While it is technically possible to specify valid formats other than color or color and linestyle (e.g. ‘rx’ or ‘-.’), this is beyond the intention of the method and will most likely not result in a reasonable reasonable plot.

markerfmt : str, optional

A string defining the properties of the markers at the stem heads. Default: ‘C0o’, i.e. filled circles with the first color of the color cycle.

basefmt : str, optional

A format string defining the properties of the baseline.

Default: ‘C3-‘ (‘C2-‘ in classic mode).

bottom : float, optional, default: 0

The y-position of the baseline.

label : str, optional, default: None

The label to use for the stems in legends.

Returns:

StemContainer

The stemcontainer may be treated like a tuple (markerline, stemlines, baseline)

Other Parameters:
 

**kwargs

No other parameters are supported. They are currently ignored silently for backward compatibility. This behavior is deprecated. Future versions will not accept any other parameters and will raise a TypeError instead.

Notes

See also

The MATLAB function stem which inspired this method.

Note

In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:

  • All positional and all keyword arguments.

Examples using matplotlib.pyplot.stem