matplotlib.pyplot.subplot
import matplotlib.pyplot as mp
for i in range(6):
mp.subplot(2, 3, i+1)
mp.xticks(())
mp.yticks(())
mp.text(.5, .5, str(i+1), ha='center', va='center', size=36, alpha=0.5)
mp.tight_layout()
mp.show()

matplotlib.pyplot.axes
import matplotlib.pyplot as mp
mp.figure(facecolor='lightgray', figsize=(2, 2))
mp.axes([0.05, 0.05, 0.9, 0.9])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '1', ha='center', va='center', size=36, alpha=0.5)
mp.axes([0.1, 0.1, 0.3, 0.3])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '2', ha='center', va='center', size=36, alpha=0.5)
mp.show()

matplotlib.gridspec.GridSpec
import matplotlib.pyplot as mp
import matplotlib.gridspec as mg
mp.figure(facecolor='lightgray')
gs = mg.GridSpec(3, 3)
for i in range(3):
for j in range(3):
mp.subplot(gs[i, j])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, str(i)+str(j), ha='center', va='center', size=36, alpha=0.5)
mp.tight_layout()
mp.show()

import matplotlib.pyplot as mp
import matplotlib.gridspec as mg
mp.figure(facecolor='lightgray')
gs = mg.GridSpec(3, 3)
mp.subplot(gs[0, :2])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '1', ha='center', va='center', size=36, alpha=0.5)
mp.subplot(gs[1:, 0])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '2', ha='center', va='center', size=36, alpha=0.5)
mp.subplot(gs[2, 1:])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '3', ha='center', va='center', size=36, alpha=0.5)
mp.subplot(gs[:2, 2])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '4', ha='center', va='center', size=36, alpha=0.5)
mp.subplot(gs[1, 1])
mp.xticks(())
mp.yticks(())
mp.text(0.5, 0.5, '5', ha='center', va='center', size=36, alpha=0.5)
mp.tight_layout()
mp.show()

Appendix
En | Cn |
---|
grid | 网格 |
specify | vt. 指定;详细说明; |
axes | n. 轴线 |
tick | n. 滴答声;记号; |
figure | 图形 |