1 回答

TA贡献1805条经验 获得超10个赞
要将单独的密度图放置在网格中,您必须将网格中的一个轴传递给绘图函数,但是,phyde.viz.density非常薄的一层seaborn.kdeplot,没有为重用预先存在的axes.
所以你必须定义¹你的薄层需要预先存在axes
def density2(ax, boot_obj, attr, p1, hyb, p2, title="", xlab="", ylab="", shade=True, color='b'):
from numpy import array
from seaborn import kdeplot, set_style
set_style("white")
kdeplot(array(boot_obj(attr, p1, hyb, p2)), shade=shade, color=color, ax=ax)
# #####
ax.set(ylabel=ylab, xlabel=xlab, title=title)
然后用于plt.subplots将各个地块排列在网格中(您在问题中提到了 5×4)
...
fig, axes = plt.subplots(5, 4, constrained_layout=True)
for row in axes:
for ax in row:
line = next(triples)
...
density2(ax, boot, 'Gamma', p1, p2, p3, title=title, xlab="Gamma", ylab="Density")
fig.savefig('You have to decide a title for the collection of plots')
添加回答
举报