如何在 Matplotlib 中爲子圖添加標題? - How to add title to subplots in Matplotlib?

問題:

I have one figure which contains many subplots.我有一個包含許多子圖的圖形。

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) 

How do I add titles to the subplots?如何爲子圖添加標題?

fig.suptitle adds a title to all graphs and although ax.set_title() exists, the latter does not add any title to my subplots. fig.suptitle爲所有圖形添加了一個標題,雖然ax.set_title()存在,但後者沒有爲我的子圖添加任何標題。

Thank you for your help.感謝您的幫助。

Edit: Corrected typo about set_title() .編輯:更正了有關set_title()錯字。 Thanks Rutger Kassies感謝 Rutger Kassies


解決方案:

參考一: https://stackoom.com/question/1hu3h
參考二: How to add title to subplots in Matplotlib?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章