第一步:创建画布实例
fig = plt.figure()
第二步:创建“区域规划图”实例(gridspec运用)
spec = gridspec.GridSpec(3,4, figure=fig)
第三步: 根据给定的“区域规划图”,创建对应的坐标系实例
ax1 = plt.subplot(spec[0,0:4]) #切片操作,实现跨列或跨行
ax2 = plt.subplot(spec[1,0:2])
ax3 = plt.subplot(spec[1,2:4])
ax4 = plt.subplot(spec[2,0:1], projection='polar')
ax5 = plt.subplot(spec[2,1:4])
plt.tight_layout()
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure()
spec = gridspec.GridSpec(3,4, figure=fig)#gridspec模块运用
ax1 = plt.subplot(spec[0,0:4])
ax2 = plt.subplot(spec[1,0:2])
ax3 = plt.subplot(spec[1,2:4])
ax4 = plt.subplot(spec[2,0:1], projection='polar')
ax5 = plt.subplot(spec[2,1:4])
plt.tight_layout() #调整子图之间的距离
plt.show()