matplotlib.axes.Axes.autoscale_view#

Axes.autoscale_view(tight=None,scalex=True,scaley=True)[source]#

Autoscale the view limits using the data limits.

Parameters:
tightbool or None

IfTrue, only expand the axis limits using the margins. Notethat unlike forautoscale,tight=True doesnot set themargins to zero.

IfFalse andrcParams["axes.autolimit_mode"] (default:'data') is 'round_numbers', thenafter expansion by the margins, further expand the axis limitsusing the axis major locator.

If None (the default), reuse the value set in the previous call toautoscale_view (the initial value is False, but the default stylesetsrcParams["axes.autolimit_mode"] (default:'data') to 'data', in which case thisbehaves like True).

scalexbool, default: True

Whether to autoscale the x-axis.

scaleybool, default: True

Whether to autoscale the y-axis.

Notes

The autoscaling preserves any preexisting axis direction reversal.

The data limits are not updated automatically when artist data arechanged after the artist has been added to an Axes instance. In thatcase, usematplotlib.axes.Axes.relim() prior to callingautoscale_view.

If the views of the Axes are fixed, e.g. viaset_xlim, they willnot be changed by autoscale_view().Seematplotlib.axes.Axes.autoscale() for an alternative.

Examples usingmatplotlib.axes.Axes.autoscale_view#

Building histograms using Rectangles and PolyCollections

Building histograms using Rectangles and PolyCollections

Packed-bubble chart

Packed-bubble chart

Line, Poly and RegularPoly Collection with autoscaling

Line, Poly and RegularPoly Collection with autoscaling

Compound path

Compound path

Ellipse Collection

Ellipse Collection

Group barchart with units

Group barchart with units

Textbox

Textbox

Autoscaling Axis

Autoscaling Axis