如何在matplotlib中为带有子图的图形添加整体标题?

J4y*_*J4y 2 python matplotlib

我可以看到您可以为每个子图添加标题,如下所示:

如何在Matplotlib中的子图中添加标题?

除了子图标题,是否可以添加整体标题?

总称号

Nil*_*ner 6

使用

fig = plt.figure()
fig.suptitle('this is the figure title')
Run Code Online (Sandbox Code Playgroud)


Glo*_*tas 5

fig = plt.figure()
plt.title('overall')
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
ax1.title.set_text('First Plot')
ax2.title.set_text('Second Plot')
ax3.title.set_text('Third Plot')
ax4.title.set_text('Fourth Plot')
plt.show()
Run Code Online (Sandbox Code Playgroud)

除了第二行之外的所有内容都是从您发布的链接中复制的。

用python 2.7测试