mplutils.get_axes_margins#

mplutils.get_axes_margins(ax=None, unit='pts')[source]#

Get the size of the margins of ax in physical units.

The margins are defined by labels, colorbars, etc.

Parameters:
axmatplotlib.axes.Axes, optional

If None, use last active axes.

unit"pts" , "mm" , "inch" , default "pts"

Unit of outputs.

Returns:
tuple[float, float, float, float]

(top, right, bottom, left) margins in units specified by unit.

Examples

>>> plt.subplot()
<Axes: >
>>> mplu.get_axes_margins()
(3.9599999999999795, 7.919999999999959, 17.079999999999995, 22.84000000000001)