# 準備畫布
fig = plt.figure()
# 添加子圖 2 * 2 的第1張圖
ax1 = fig.add_subplot(221)
# 添加子圖 2 * 2 的第2張圖
ax2 = fig.add_subplot(222)
# 添加子圖 2 * 2 的第3張圖
ax3 = fig.add_subplot(223)
# 添加子圖 2 * 2 的第4張圖
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')
# 設置子圖邊距和間隔
left = 0.125 # the left side of the subplots of the figure
right = 0.9 # the right side of the subplots of the figure
bottom = 0.1 # the bottom of the subplots of the figure
top = 0.9 # the top of the subplots of the figure
wspace = 0.2 # the amount of width reserved for blank space between subplots,
# expressed as a fraction of the average axis width
hspace = 0.2 # the amount of height reserved for white space between subplots,
# expressed as a fraction of the average axis height
plt.subplots_adjust(left=left, bottom=bottom, right=right, top=top,
wspace=wspace, hspace=hspace)
# 展示
plt.show()
Matplotlib子圖相關操作
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.