GridSpec是布置子打印网格的一种灵活方式。下面是一个使用3x3网格和横跨所有三列、两列和两行的轴的示例。import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec def format_axes(fig): for i, ax in enumerate(fig.axes): ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="...
ax0=fig.add_subplot(spec[0]) 如上所述,ax0对象在地物中的位置为0,或者可以使用spec[0, 0]使它更清晰。 gridspec_kw方法 importmatplotlib.pyplotasplt fig,ax=plt.subplots(2,2,gridspec_kw={"width_ratios":[2,1],"height_ratios":[1,2]})ax[0][0].plot(range(5),range(5,10))ax[0][1...