matplotlib._tight_layout#

调整子图参数的例程,使子图在图中完美适配。在此过程中,目前只考虑轴标签、刻度标签、Axes标题以及锚定到Axes的偏移框。

内部地,此模块假定(左边距等)边距,即 Axes.get_tightbboxAxes.bbox 之间的差值,与 Axes 位置无关。如果 Axes.adjustabledatalim,以及左或右边距受 xlabel 影响的情况,这可能会失败。

matplotlib._tight_layout.get_subplotspec_list(axes_list, grid_spec=None)[source]#

返回给定 Axes 列表中的 subplotspec 列表。

对于不支持 subplotspec 的 Axes 实例,None 将被插入到列表中。

如果给定了 grid_spec,则对于不属于给定 grid_spec 的项,None 将被插入。

matplotlib._tight_layout.get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad=1.08, h_pad=None, w_pad=None, rect=None)[source]#

返回带有指定填充的紧密布局图的子图参数。

参数:
figFigure
axes_listAxes 列表
subplotspec_listSubplotSpec 列表

每个 Axes 的 subplotspecs。

rendererrenderer
pad浮点数

图形边缘和子图边缘之间的填充,作为字体大小的一部分。

h_pad, w_padfloat

相邻子图边缘之间的填充(高度/宽度)。默认为 pad

rect元组 (left, bottom, right, top),默认值: None。

在标准化图坐标系中,整个子图区域(包括标签)将适配的矩形。默认为使用整个图。

返回:
subplotspec 或 None

要传递给 Figure.subplots_adjust 的 subplotspec 关键字参数,或者如果无法完成 tight_layout 则为 None。