subplot2grid()可以通过rowspan和colspan参数让子区跨越固定的网格布局的多个行与列。
subplot2grid()语法格式:
subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs)
利用subplot2grid()修改下列代码
%matplotlib auto
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ["SimHei"]
x = [x for x in range(1, 13)]
y1 = [20, 28, 23, 16, 29, 36, 39, 33, 31, 19, 21, 25]
y2 = [17, 22, 39, 26, 35, 23, 25, 27, 29, 38, 28, 20]
labels = ['1 月', '2 月', '3 月', '4 月', '5 月', '6 月', '7月', '8 月', '9 月', '10 月', '11 月', '12 月']
# 绘制第一个子图
ax1 = plt.subplot2grid((2,4), (0,1), colspan=2)
ax1.plot(x, y1, 'm--o', lw=2, ms&#