matplotlib.axes.Axes.add_collection#

Axes.add_collection(collection, autolim=True)[source]#

Add a Collection to the Axes; return the collection.

Parameters:
collectionCollection

The collection to add.

autolimbool

Whether to update data and view limits.

If False, the collection does not take part in any limit operations.

Changed in version 3.11: Since 3.11 autolim=True matches the standard behavior of other add_[artist] methods: Axes data and view limits are both updated in the method, and the collection will be considered in future data limit updates through relim.

Prior to matplotlib 3.11 this was only a one-time update of the data limits. Updating view limits required an explicit call to autoscale_view, and collections did not take part in relim.

As an implementation detail, the value "_datalim_only" is supported to smooth the internal transition from pre-3.11 behavior. This is not a public interface and will be removed again in the future.

Examples using matplotlib.axes.Axes.add_collection#

EventCollection Demo

EventCollection Demo

Multicolored lines

Multicolored lines

Create boxes from error bars using PatchCollection

Create boxes from error bars using PatchCollection

Line, Poly and RegularPoly Collection

Line, Poly and RegularPoly Collection

Ellipse Collection

Ellipse Collection

Plot multiple lines using a LineCollection

Plot multiple lines using a LineCollection

Circles, Wedges and Polygons

Circles, Wedges and Polygons

Lasso Demo

Lasso Demo

Artist tests

Artist tests