调用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()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)