matplotlib 3.5.1

NotesParametersReturnsBackRef
stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label=None, use_line_collection=True, orientation='vertical', data=None)

A stem plot draws lines perpendicular to a baseline at each location locs from the baseline to heads, and places a marker there. For vertical stem plots (the default), the locs are x positions, and the heads are y values. For horizontal stem plots, the locs are y positions, and the heads are x values.

Call signature:

stem([locs,] heads, linefmt=None, markerfmt=None, basefmt=None)

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

Notes

.. seealso:: 
    The MATLAB function
    `stem <https://www.mathworks.com/help/matlab/ref/stem.html>`_
    which inspired this method.

Parameters

locs : array-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.

heads : array-like

For vertical stem plots, the y-values of the stem heads. For horizontal stem plots, the x-values of the stem heads.

linefmt : str, 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 color cycle.

Note: Markers specified through this parameter (e.g. 'x') will be silently ignored (unless using use_line_collection=False ). Instead, markers should be specified using markerfmt.

markerfmt : str, optional

A string defining the color and/or shape of the markers at the stem heads. Default: 'C0o', i.e. filled circles with the first color of the color cycle.

basefmt : str, default: 'C3-' ('C2-' in classic mode)

A format string defining the properties of the baseline.

orientation : str, default: 'vertical'

If 'vertical', will produce a plot with stems oriented vertically, otherwise the stems will be oriented horizontally.

bottom : float, default: 0

The y/x-position of the baseline (depending on orientation).

label : str, default: None

The label to use for the stems in legends.

use_line_collection : bool, default: True

If True , store and plot the stem lines as a ~.collections.LineCollection instead of individual lines, which significantly increases performance. If False , defaults to the old behavior of using a list of .Line2D objects. This parameter may be deprecated in the future.

data : indexable object, optional

If given, all parameters also accept a string s , which is interpreted as data[s] (unless this raises an exception).

Returns

`.StemContainer`

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

Create a stem plot.

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.legend_handler.HandlerStem

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/axes/_axes.py#2758
type: <class 'function'>
Commit: