1 回答

TA貢獻1805條經驗 獲得超10個贊
要將單獨的密度圖放置在網格中,您必須將網格中的一個軸傳遞給繪圖函數,但是,phyde.viz.density非常薄的一層seaborn.kdeplot,沒有為重用預先存在的axes.
所以你必須定義1你的薄層需要預先存在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')
添加回答
舉報