MCPcopy
hub / github.com/matplotlib/matplotlib / margins

Method margins

lib/matplotlib/axes/_base.py:2914–2995  ·  view source on GitHub ↗

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 `~.Axes.set_xlim` / `~.Axes.set_ylim`. Autoscaling determines the axis limits by adding *margin* ti

(self, *margins, x=None, y=None, tight=True)

Source from the content-addressed store, hash-verified

2912 self.stale = True
2913
2914 def margins(self, *margins, x=None, y=None, tight=True):
2915 """
2916 Set or retrieve margins around the data for autoscaling axis limits.
2917
2918 This allows to configure the padding around the data without having to
2919 set explicit limits using `~.Axes.set_xlim` / `~.Axes.set_ylim`.
2920
2921 Autoscaling determines the axis limits by adding *margin* times the
2922 data interval as padding around the data. See the following illustration:
2923
2924 .. plot:: _embedded_plots/axes_margins.py
2925
2926 All input parameters must be floats greater than -0.5. Passing both
2927 positional and keyword arguments is invalid and will raise a TypeError.
2928 If no arguments (positional or otherwise) are provided, the current
2929 margins will remain unchanged and simply be returned.
2930
2931 The default margins are :rc:`axes.xmargin` and :rc:`axes.ymargin`.
2932
2933 Parameters
2934 ----------
2935 *margins : float, optional
2936 If a single positional argument is provided, it specifies
2937 both margins of the x-axis and y-axis limits. If two
2938 positional arguments are provided, they will be interpreted
2939 as *xmargin*, *ymargin*. If setting the margin on a single
2940 axis is desired, use the keyword arguments described below.
2941
2942 x, y : float, optional
2943 Specific margin values for the x-axis and y-axis,
2944 respectively. These cannot be used with positional
2945 arguments, but can be used individually to alter on e.g.,
2946 only the y-axis.
2947
2948 tight : bool or None, default: True
2949 The *tight* parameter is passed to `~.axes.Axes.autoscale_view`,
2950 which is executed after a margin is changed; the default
2951 here is *True*, on the assumption that when margins are
2952 specified, no additional padding to match tick marks is
2953 usually desired. Setting *tight* to *None* preserves
2954 the previous setting.
2955
2956 Returns
2957 -------
2958 xmargin, ymargin : float
2959
2960 Notes
2961 -----
2962 If a previously used Axes method such as :meth:`pcolor` has set
2963 `~.Axes.use_sticky_edges` to `True`, only the limits not set by
2964 the "sticky artists" will be modified. To force all
2965 margins to be set, set `~.Axes.use_sticky_edges` to `False`
2966 before calling :meth:`margins`.
2967
2968 See Also
2969 --------
2970 :ref:`autoscale_margins`
2971 .Axes.set_xmargin, .Axes.set_ymargin

Callers 15

marginsFunction · 0.45
test_quiver_with_keyFunction · 0.45
test_quiver_singleFunction · 0.45
test_twinx_axis_scalesFunction · 0.45
test_o_marker_path_snapFunction · 0.45
test_marginsFunction · 0.45
test_margin_gettersFunction · 0.45
test_margins_errorsFunction · 0.45
test_box_aspectFunction · 0.45

Calls 2

set_xmarginMethod · 0.95
set_ymarginMethod · 0.95

Tested by 12

test_quiver_with_keyFunction · 0.36
test_quiver_singleFunction · 0.36
test_twinx_axis_scalesFunction · 0.36
test_o_marker_path_snapFunction · 0.36
test_marginsFunction · 0.36
test_margin_gettersFunction · 0.36
test_margins_errorsFunction · 0.36
test_box_aspectFunction · 0.36