python中使用matplotlib模塊的add_subplot函數添加子圖,具體方法如下:
from matplotlib import pyplot as plt #導入matplotlib模塊
fig = plt.figure()
ax1 = fig.add_subplot(231)
ax2 = fig.add_subplot(232)
ax3 = fig.add_subplot(233)
ax4 = fig.add_subplot(234)
ax5 = fig.add_subplot(235)
ax6 = fig.add_subplot(236)
plt.grid(True)
plt.show()
效果圖: