【发布时间】:2016-08-04 18:46:18
【问题描述】:
我在 3x3 网格中有一系列 9 个子图,每个子图都有一个标题。 我想为每一行添加一个标题。为此,我考虑过使用字幕。 问题是如果我使用 3 个字幕,它们似乎会被覆盖,并且似乎只显示最后一个。
这是我的基本代码:
fig, axes = plt.subplots(3,3,sharex='col', sharey='row')
for j in range(9):
axes.flat[j].set_title('plot '+str(j))
plt1 = fig.suptitle("row 1",x=0.6,y=1.8,fontsize=18)
plt2 = fig.suptitle("row 2",x=0.6,y=1.2,fontsize=18)
plt3 = fig.suptitle("row 3",x=0.6,y=0.7,fontsize=18)
fig.subplots_adjust(right=1.1,top=1.6)
【问题讨论】:
-
为什么不只使用轴 1、4、7 的
set_title(j%3 == 1) 并清除其余部分? -
因为我仍然需要每个子图的标题,以及行的标题
-
每个图只能有一个
suptitle。我建议使用text对象作为行标题 -
我想我必须接受这个
标签: python matplotlib title subplot