我终于成功地将我的 hexbin 分布图整理成几乎漂亮的东西。
import seaborn as sns
x = req.apply_clicks
y = req.reqs_wordcount
sns.jointplot(x, y, kind="hex", color="#5d5d60",
joint_kws={'gridsize':40, 'bins':'log'})
但我希望在其上覆盖一条回归线,但不知道如何做到这一点。例如,当我将 regplot 添加到代码中时,回归线似乎占据了边缘图:
x = req.apply_clicks
y = req.reqs_wordcount
z = sns.jointplot(x, y, kind="hex", color="#5d5d60",
joint_kws={'gridsize':40, 'bins':'log'})
sns.regplot(x, y, data=z, color="#5d5d60", scatter=False)
如何将回归线包含在图表主体中?
您需要指定您想要的轴regplot
出现在.这是一个示例,其中包含一些虚构的数据:
import seaborn as sns
import numpy as np
x = 0.3 + 0.3 * np.random.randn(10000)
y = 0.1 - 0.2 * x + 0.1 * np.random.randn(10000)
mask = (y > 0) & (x > 0)
x, y = x[mask], y[mask]
g = sns.jointplot(x, y, kind="hex", color="#5d5d60",
joint_kws={'gridsize':40, 'bins':'log'})
sns.regplot(x, y, ax=g.ax_joint, scatter=False)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)