1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| import matplotlib.pyplot as plt import matplotlib.gridspec as grid
############ method1 ############ # fig = plt.figure(num = 15,figsize=(8,5)) # # 从0,0 开始,占3行,3列,采取了一个行三个列的图 # ax1 = plt.subplot2grid((3,3),(0,0),colspan=3,rowspan=1) # ax1.plot([1,2],[1,2]) # ax1.set_title('ax1_title')
# ax2 = plt.subplot2grid((3,3),(1,0),colspan=2) # ax2.plot([1,2],[1,2])
# ax3 = plt.subplot2grid((3,3),(1,2),rowspan=2) # ax4 = plt.subplot2grid((3,3),(2,0)) # ax4 = plt.subplot2grid((3,3),(2,1))
############# method2 ########### # fig = plt.figure(num = 15,figsize=(8,5)) # gs = grid.GridSpec(3,3) # ax1 = plt.subplot(gs[0,:]) # ax2 = plt.subplot(gs[1,:2]) # ax3 = plt.subplot(gs[1:,2]) # ax4 = plt.subplot(gs[-1,0]) # ax5 = plt.subplot(gs[-1,-2])
############ method3 ########### f,((ax11,ax12),(ax21,ax22)) = plt.subplots(2,2,sharex=True) ax11.scatter([1,2],[1,2])
plt.tight_layout() plt.show()
CLEAN
|