多くのサブプロットを含む図が 1 つあります。
fig = plt.figure(num=None, figsize=(26, 12), dpi=80, facecolor='w', edgecolor='k')
fig.canvas.set_window_title('Window Title')
# Returns the Axes instance
ax = fig.add_subplot(311)
ax2 = fig.add_subplot(312)
ax3 = fig.add_subplot(313)
サブプロットにタイトルを追加するにはどうすればよいですか?
fig.suptitle
すべてのグラフにタイトルを追加しますが、ax.set_title()
後者は存在するにもかかわらず、サブプロットにタイトルを追加しません。
助けてくれてありがとう。
編集: についてタイプミスを修正しましたset_title()
。ありがとう、Rutger Kassies
ベストアンサー1
ax.title.set_text('My Plot Title')
も動作するようです。
fig = plt.figure()
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()