matplotlib.axes.Axes.margins#

Axes.margins(*margins, x=None, y=None, tight=True)[source]#

Set or retrieve margins around the data for autoscaling axis limits.

This allows to configure the padding around the data without having to set explicit limits using set_xlim / set_ylim.

Autoscaling determines the axis limits by adding margin times the data interval as padding around the data. See the following illustration:

(Source code, png)