matplotlib.axes.Axes.stem#
- Axes.stem(*args,linefmt=None,markerfmt=None,basefmt=None,bottom=0,label=None,orientation='vertical',data=None)[source]#
Create a stem plot.
A stem plot draws lines perpendicular to a baseline at each locationlocs from the baseline toheads, and places a marker there. Forvertical stem plots (the default), thelocs arex positions, andtheheads arey values. For horizontal stem plots, thelocs arey positions, and theheads arex values.
Call signature:
stem([locs,]heads,linefmt=None,markerfmt=None,basefmt=None)
Thelocs-positions are optional.linefmt may be provided aspositional, but all other formats must be provided as keywordarguments.
- Parameters:
- locsarray-like, default: (0, 1, ..., len(heads) - 1)
For vertical stem plots, the x-positions of the stems.For horizontal stem plots, the y-positions of the stems.
- headsarray-like
For vertical stem plots, the y-values of the stem heads.For horizontal stem plots, the x-values of the stem heads.
- linefmtstr, optional
A string defining the color and/or linestyle of the vertical lines:
Character
Line Style
'-'
solid line
'--'
dashed line
'-.'
dash-dot line
':'
dotted line
Default: 'C0-', i.e. solid line with the first color of the colorcycle.
Note: Markers specified through this parameter (e.g. 'x') will besilently ignored. Instead, markers should be specified usingmarkerfmt.
- markerfmtstr, optional
A string defining the color and/or shape of the markers at the stemheads. If the marker is not given, use the marker 'o', i.e. filledcircles. If the color is not given, use the color fromlinefmt.
- basefmtstr, default: 'C3-' ('C2-' in classic mode)
A format string defining the properties of the baseline.
- orientation{'vertical', 'horizontal'}, default: 'vertical'
The orientation of the stems.
- bottomfloat, default: 0
The y/x-position of the baseline (depending onorientation).
- labelstr, optional
The label to use for the stems in legends.
- dataindexable object, optional
If given, all parameters also accept a string
s
, which isinterpreted asdata[s]
ifs
is a key indata
.
- Returns:
StemContainer
The container may be treated like a tuple(markerline,stemlines,baseline)
Notes
See also
The MATLAB functionstemwhich inspired this method.