matplotlib.axes.Axes.get_tightbbox

Axes.get_tightbbox(renderer, call_axes_locator=True, bbox_extra_artists=None, *, for_layout_only=False)

返回轴的紧边界框,包括轴及其装饰器(xlabel、title等)。

艺术家们 artist.set_in_layout(False) 不包括在bbox中。

参数:
渲染器RendererBase 子类RenderBase子类

将用于绘制图形的渲染器(即 fig.canvas.get_renderer()

bbox_extra_artists 名单 ArtistNone名单

要包含在紧边界框中的艺术家列表。如果 None (默认),则轴的所有艺术家子级都包含在紧边界框中。

call_axes_locatorbool,默认值:True

如果 call_axes_locatorFalse ,它不调用 _axes_locator 属性,这是获取正确边界框所必需的。 call_axes_locator=False 如果调用方只对与轴bbox相比的紧密bbox的相对大小感兴趣,则可以使用。

for_layout_only默认值:False

边界框将 not 包括标题的x范围和xlabel,或ylabel的y范围。

返回:
BboxBase

图形像素坐标中的边界框。

使用实例 matplotlib.axes.Axes.get_tightbbox