为什么我在 seaborn 线图中出现线阴影?

2024-03-29

这是代码:

fig=plt.figure(figsize=(14,8))
sns.lineplot(x='season', y='team_strikerate', hue='batting_team', data=overall_batseason)
plt.legend(title = 'Teams', loc = 1, fontsize = 12)
plt.xlim([2008,2022])

And here is the image enter image description here

只是为了让您知道,我已经在此之上绘制了另一个类似的线图。


有线阴影显示置信区间,因为数据集包含多重y(团队打击率) 值对于每个 x(season) 价值。默认情况下,sns.lineplot() https://seaborn.pydata.org/generated/seaborn.lineplot.html将估计mean by 聚合每个 x 值处的多个 y 值。

聚合后,将y 的平均值每个 x 值处的值将绘制为line. The 线阴影代表95% 置信区间的估计。


要删除线条阴影,可以传递参数ci=None to sns.lineplot()。 (感谢 @JohanC 在这个问题中提供了这个想法comment https://stackoverflow.com/questions/62897548/why-am-i-getting-a-line-shadow-in-a-seaborn-line-plot#comment111227283_62897548)

要更改置信区间,您可以传递参数errorbar=('ci', <int>) to sns.lineplot().

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么我在 seaborn 线图中出现线阴影? 的相关文章

随机推荐