import matplotlib.pyplot as plt
plt.figure()
plt.subplot(2, 2, 1)
plt.plot([0, 1], [0, 1])
plt.subplot(2, 2, 2)
plt.plot([4, 1], [0, 1])
plt.subplot(2, 2, 3)
plt.plot([0, 2], [0, 1])
plt.subplot(2, 2, 4)
plt.plot([0, 1], [0, 4])
plt.show()
plt.subplot(2, 2, 1)------把figure分成2*2的块,并在第一个画图
那如果我们要达到下图的效果怎么做呢?
仔细看怎么分的块
plt.figure()
plt.subplot(2, 1, 1)
plt.plot([0, 1], [0, 1])
plt.subplot(2, 3, 4)
plt.plot([4, 1], [0, 1])
plt.subplot(2, 3, 5)
plt.plot([0, 2], [0, 1])
plt.subplot(2, 3, 6)
plt.plot([0, 1], [0, 4])
plt.show()
另外一种写法比较好理解
可以分别对ax进行操作,但是方法前面都加有set_
plt.figure()
ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3, rowspan=