matplotlib.pyplot.margins
-
matplotlib.pyplot.margins(*margins, x=None, y=None, tight=True)
[source] -
Set or retrieve autoscaling margins.
The padding added to each limit of the axes is the margin times the data interval. All input parameters must be floats within the range [0, 1]. Passing both positional and keyword arguments is invalid and will raise a TypeError. If no arguments (positional or otherwise) are provided, the current margins will remain in place and simply be returned.
Specifying any margin changes only the autoscaling; for example, if xmargin is not None, then xmargin times the X data interval will be added to each end of that interval before it is used in autoscaling.
Parameters: -
*marginsfloat, optional
-
If a single positional argument is provided, it specifies both margins of the x-axis and y-axis limits. If two positional arguments are provided, they will be interpreted as xmargin, ymargin. If setting the margin on a single axis is desired, use the keyword arguments described below.
-
x, yfloat, optional
-
Specific margin values for the x-axis and y-axis, respectively. These cannot be used with positional arguments, but can be used individually to alter on e.g., only the y-axis.
-
tightbool or None, default is True
-
The tight parameter is passed to
autoscale_view()
, which is executed after a margin is changed; the default here is True, on the assumption that when margins are specified, no additional padding to match tick marks is usually desired. Set tight to None will preserve the previous setting.
Returns: -
xmargin, ymarginfloat
Notes
If a previously used Axes method such as
pcolor()
has setuse_sticky_edges
toTrue
, only the limits not set by the "sticky artists" will be modified. To force all of the margins to be set, setuse_sticky_edges
toFalse
before callingmargins()
. -
Examples using matplotlib.pyplot.margins
© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.margins.html