栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

调用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()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/669209.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号