作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我终于设法将我的 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)
关于python - 如何使用 Seaborn 在 hexbins 上绘制回归线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33288830/
我想创建这样的情节: 这里我们有两个变量 X = midyear 和 Y = yearend。我想为 Y 的 X 的每个级别创建密度图。 我可以做到这一点,但看起来并不像我想象的那样,特别是情节和线条
我正在尝试在数据框的行上应用公式来获取行中数字的趋势。 下面的示例在使用 .apply 的部分之前一直有效。 df = pd.DataFrame(np.random.randn(10, 4), col
我是一名优秀的程序员,十分优秀!