我正在使用一些返回 matplotlib.axes 对象的代码。我使用的代码是https://github.com/pblischak/HyDe/blob/master/phyde/visualize/viz.py上的 def_density() 函数 在一个循环中,我打开一个数据文件,解析每一行,输入一些数据,创建一个 matplotlib.axes 对象(使用 seaborn.kdeplot() 方法),提取图像,然后将图像写入文件。这很好用,但我只剩下每个文件行一张图像。我真正想做的是收集所有图像,将它们放在网格中并只创建一个图像。我不会提前知道有多少图像(当然我可以先计算行数,然后使用该信息重新遍历文件)。
这是我的代码
import phyde as hd
import os
import sys
bootfile = sys.argv[1]
triplesfile = sys.argv[2]
boot = hd.Bootstrap(bootfile)
triples=open(triplesfile, "r")
next(triples)
for line in triples:
triple = line.split()
p1=triple[0]
p2=triple[1]
p3=triple[2]
title="Bootstrap Dist. of Gamma for "+p1+", "+p2+", and "+p3
image= hd.viz.density(boot, 'Gamma', p1, p2, p3, title=title, xlab="Gamma", ylab="Density")
fig = image.get_figure()
figname="density_"+p1+"_"+p2+"_"+p3+".png"
fig.savefig(figname)
我的问题是,如果我说要在 5 x 4 网格中设置 20 个地块,我该怎么做?我已经使用我在此处找到的示例尝试了许多不同的方法,但似乎没有任何效果(plt.subplots() 是我玩过的东西)。任何建议都将非常受欢迎!
 德玛西亚99
德玛西亚99 
					holdtom
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类