ax1.set_title('ax1_title')
ax2=plt.subplot2grid((3,3),(1,0),colspan=2,rowspan=1)
ax2.plot([2,4,6],[7,9,15...])
ax3=plt.subplot2grid((3,3),(1,2),colspan=1,rowspan=1)
x = np.arange(4)
y = np.array([15,20,18,25])...ax3.bar(x,y)
ax4=plt.subplot2grid((3,3),(2,0),colspan=1,rowspan=1)
ax5=plt.subplot2grid((3,3),(2,1),...colspan=2,rowspan=1)
效果如下:
结合图可能更好理解一点,其中代码:
plt.subplot2grid((3,3),(0,0),colspan=3,rowspan=1)
第一个参数...(3,3)相当于格子分成3行3列,第二个参数(0,0)表示该子图的开始位置,colspan=3表示子图的列跨度为3,rowspan=1表示子图的行跨度为1。