plt.subplot(221)
# equivalent but more general
# 子圖1
ax1 = plt.subplot(2, 2, 1)
# add a subplot with no frame
# 子圖2
ax2 = plt.subplot(222, frameon=False)
# add a polar subplot
# 子圖3
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
# 子圖4
plt.subplot(224, sharex=ax1, facecolor='red')
刪除一個子圖。
plt.subplot(221)
# equivalent but more general
ax1 = plt.subplot(2, 2, 1)
# add a subplot with no frame
ax2 = plt.subplot(222, frameon=False)
# add a polar subplot
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
plt.subplot(224, sharex=ax1, facecolor='red')
# delete ax2 from the figure
plt.delaxes(ax2)
x = [1,2,3]
y1 = x
y2 = [4,5,6]
y3 = [7,8,9]
y4 = [12,9,11]
ax1 = plt.subplot(221)
ax1.margins(0.05)
ax1.plot(x,y1)
# 標題
ax1.set_title('1',loc='left')
ax2 = plt.subplot(222)
ax2.margins(0.05)
ax2.plot(x,y2)
# 標題
ax2.set_title('2')
ax3 = plt.subplot(223)
ax3.margins(0.05)
ax3.plot(x,y3)
# 標題
ax3.set_title('3')
ax4 = plt.subplot(224)
ax4.margins(0.05)
ax4.plot(x,y3)
# 標題
ax4.set_title('4')