matplotlib.container#

classmatplotlib.container.BarContainer(*args,**kwargs)[source]#

Bases:Container

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

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

Attributes:
patcheslist ofRectangle

The artists of the bars.

errorbarNone orErrorbarContainer

A container for the error bar artists if error bars are present.None otherwise.

datavaluesNone or array-like

The underlying data values corresponding to the bars.

orientation{'vertical', 'horizontal'}, default: None

If 'vertical', the bars are assumed to be vertical.If 'horizontal', the bars are assumed to be horizontal.

propertybottoms#

Return the values at the lower end of the bars.

Added in version 3.11.

propertyposition_centers#

Return the centers of bar positions.

Added in version 3.11.

propertytops#

Return the values at the upper end of the bars.

Added in version 3.11.

classmatplotlib.container.Container(*args,**kwargs)[source]#

Bases:tuple

Base class for containers.

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

add_callback(func)[source]#

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

Parameters:
funccallable

The callback function. It must have the signature:

deffunc(artist:Artist)->Any

whereartist is the callingArtist. Return values may existbut are ignored.

Returns:
int

The observer id associated with the callback. This id can beused for removing the callback withremove_callback later.

get_children()[source]#
get_label()[source]#

Return the label used for this artist in the legend.

pchanged()[source]#

Call all of the registered callbacks.

This function is triggered internally when a property is changed.

remove()[source]#
remove_callback(oid)[source]#

Remove a callback based on its observer id.

See also

add_callback
set_label(s)[source]#

Set a label that will be displayed in the legend.

Parameters:
sobject

s will be converted to a string by callingstr.

classmatplotlib.container.ErrorbarContainer(*args,**kwargs)[source]#

Bases:Container

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

The container can be treated as thelines tuple itself.Additionally, you can access these and further parameters by theattributes.

Attributes:
linestuple

Tuple of(data_line,caplines,barlinecols).

  • data_line : ALine2D instance of x, y plot markersand/or line.

  • caplines : A tuple ofLine2D instances of the errorbar caps.

  • barlinecols : A tuple ofLineCollection with thehorizontal and vertical error ranges.

has_xerr, has_yerrbool

True if the errorbar has x/y errors.

classmatplotlib.container.PieContainer(wedges,values,normalize)[source]#

Bases:object

Container for the artists of pie charts (e.g. created byAxes.pie).

Added in version 3.11.

Warning

The class namePieContainer name is provisional and may change in futureto reflect development of its functionality.

You can access the wedge patches and further parameters by the attributes.

Attributes:
wedgeslist ofWedge

The artists of the pie wedges.

valuesnumpy.ndarray

The data that the pie is based on.

fracsnumpy.ndarray

The fraction of the pie that each wedge represents.

textslist of list ofText

The artists of any labels on the pie wedges. Each inner list has onetext label per wedge.

add_texts(texts)[source]#

Add a list ofText objects to the container.

propertyfracs#
remove()[source]#

Remove all wedges and texts from the axes

propertytexts#
propertyvalues#
classmatplotlib.container.StemContainer(*args,**kwargs)[source]#

Bases:Container

Container for the artists created in aAxes.stem() plot.

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

Attributes:
markerlineLine2D

The artist of the markers at the stem heads.

stemlinesLineCollection

The artists of the vertical lines for all stems.

baselineLine2D

The artist of the horizontal baseline.

Parameters:
markerline_stemlines_baselinetuple

Tuple of(markerline,stemlines,baseline).markerline contains theLine2D of the markers,stemlines is aLineCollection of the main lines,baseline is theLine2D of the baseline.