# matplotlib.container¶

class matplotlib.container.BarContainer(*args, **kwargs)[source]

Container for the artists of bar plots (e.g. created by Axes.bar).

The container can be treated as a tuple of the patches themselves. Additionally, you can access these and further parameters by the attributes.

Attributes: patcheslist of RectangleThe artists of the bars. errorbarNone or ErrorbarContainerA container for the error bar artists if error bars are present. None otherwise.
class matplotlib.container.Container(*args, **kwargs)[source]

Bases: tuple

Base class for containers.

Containers are classes that collect semantically related Artists such as the bars of a bar plot.

add_callback(self, func)

Add a callback function that will be called whenever one of the Artist's properties changes.

Parameters: funccallableThe callback function. It must have the signature: def func(artist: Artist) -> Any  where artist is the calling Artist. Return values may exist but are ignored. intThe observer id associated with the callback. This id can be used for removing the callback with remove_callback later.
get_children(self)[source]
get_label(self)

Return the label used for this artist in the legend.

pchanged(self)

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

remove(self)[source]
remove_callback(self, oid)

Remove a callback based on its observer id.

set_label(self, s)

Set a label that will be displayed in the legend.

Parameters: sobjects will be converted to a string by calling str.
class matplotlib.container.ErrorbarContainer(*args, **kwargs)[source]

Container for the artists of error bars (e.g. created by Axes.errorbar).

The container can be treated as the lines tuple itself. Additionally, you can access these and further parameters by the attributes.

Attributes: linestupleTuple of (data_line, caplines, barlinecols). data_line : Line2D instance of x, y plot markers and/or line. caplines : tuple of Line2D instances of the error bar caps. barlinecols : list of LineCollection with the horizontal and vertical error ranges. has_xerr, has_yerrboolTrue if the errorbar has x/y errors.
class matplotlib.container.StemContainer(*args, **kwargs)[source]

Container for the artists created in a Axes.stem() plot.

The container can be treated like a namedtuple (markerline, stemlines, baseline).

Attributes: markerlineLine2DThe artist of the markers at the stem heads. stemlineslist of Line2DThe artists of the vertical lines for all stems. baselineLine2DThe artist of the horizontal baseline.
Parameters: markerline_stemlines_baselinetupleTuple of (markerline, stemlines, baseline). markerline contains the LineCollection of the markers, stemlines is a LineCollection of the main lines, baseline is the Line2D of the baseline.