標籤:

Matplotlib學習-12分格顯示

import matplotlib.pyplot as pltimport matplotlib.gridspec as gridspec#method1:subplot2grid############plt.figure()ax1 = plt.subplot2grid((3,3),(0,0),colspan=3,rowspan=1)#3行3列,起始(0,0)列3,行1ax1.plot([1,2],[1,2])ax1.set_title(ax1_title)ax2 = plt.subplot2grid((3,3),(1,0),colspan=2,rowspan=1)ax3 = plt.subplot2grid((3,3),(1,2),rowspan=2)ax4 = plt.subplot2grid((3,3),(2,0))ax5 = plt.subplot2grid((3,3),(2,1))#method2:gridspec####################plt.figure()gs = gridspec.GridSpec(3,3) #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,1])#最後一行,第二列#method3:easy to define structure#######################f,((ax11,ax12),(ax21,ax22)) = plt.subplots(2,2,sharex=True,sharey=True)ax11.plot([1,2],[2,1])plt.tight_layout()plt.show()

推薦閱讀:

基於matplotlib的2D/3D抽象網格和能量曲線繪製程序
python matplotlib 繪圖
AxesSubplot.set_title, .imshow
Seaborn(sns)官方文檔學習筆記(第五章 分類數據的繪製)
Win7、Python3.6安裝Numpy+MKL、SciPy、matplotlib、scikit-learn

TAG:Matplotlib |