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 for
autoscale
,tight=True
doesnot set themargins to zero.IfFalse and
rcParams["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 to
autoscale_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, use
matplotlib.axes.Axes.relim()
prior to callingautoscale_view.If the views of the Axes are fixed, e.g. via
set_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

Line, Poly and RegularPoly Collection with autoscaling