某些子图之间的间距,但不是全部

某些子图之间的间距,但不是全部,第1张

某些子图之间的间距,但不是全部

调用update时,您会将这些参数应用于该特定gridspec中的所有子图。如果要对不同的子图使用不同的参数,则可以制作多个网格规格。但是,您需要确保它们的大小正确且不会重叠。做到这一点的一种方法是使用嵌套的gridspec。由于底部两个图的总高度是顶部的6倍,因此外部网格规格的高度比为[1,6]。

import matplotlib.pyplot as pltimport matplotlib.gridspec as gridspecdef do_stuff(cell): #just so the plots show up    ax = plt.subplot(cell)    ax.plot()    ax.get_xaxis().set_visible(False)    ax.get_yaxis().set_visible(False)plt.subplots_adjust(hspace=0.0)#make outer gridspecouter = gridspec.GridSpec(2, 1, height_ratios = [1, 6]) #make nested gridspecsgs1 = gridspec.GridSpecFromSubplotSpec(1, 1, subplot_spec = outer[0])gs2 = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec = outer[1], hspace = .05)for cell in gs1:    do_stuff(cell)for cell in gs2:    do_stuff(cell)plt.show()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5674458.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存