plt.figure(0)
axes1 = plt.subplot2grid((3,3), (0,0), colspan=3)#(0,0)开始,占3列
axes2 = plt.subplot2grid((3,3), (1,0), colspan=2)#(1,0)开始,占2列
axes3 = plt.subplot2grid((3,3), (1,2))
axes4 = plt.subplot2grid((3,3), (2,0))
axes5 = plt.subplot2grid((3,3), (2,1),colspan=2)
all_axes = plt.gcf().axes
for ax in all_axes:
for ticklabel in ax.get_xticklabels() + ax.get_yticklabels():
ticklabel.set_fontsize(10)
plt.suptitle('Demo of subplot2grid')
plt.show()
subplot2grid
参数有shape, loc以及可选的参数colspan
,rowspan
,它和figure.add_subplot
一个重要的不同是loc位置是从0下标开始的