matplotlib.figure.Figure.align_titles#

Figure.align_titles(axs=None)[源代码]#

如果标题对齐是自动进行的(即标题位置未手动设置),则对齐同一子图行中的子图标题。

调用此方法后,对齐方式在绘制事件中持续有效。

参数:
axs : Axes 的列表列表

可选的 Axes 列表(或 ndarray)以对齐标题。默认是对齐图中的所有 Axes。

注释

这假设 axs 来自同一个 GridSpec,因此它们的 SubplotSpec 位置对应于图形位置。

示例

带有标题的示例:

fig, axs = plt.subplots(1, 2)
axs[0].set_aspect('equal')
axs[0].set_title('Title 0')
axs[1].set_title('Title 1')
fig.align_titles()

使用 matplotlib.figure.Figure.align_titles 的示例#

对齐标签和标题

Align labels and titles