Seaborn中的Lineplot是"spikey". [英] Lineplot in Seaborn is "spikey"

查看:92
本文介绍了Seaborn中的Lineplot是"spikey".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Seaborn还是陌生的,并且我计划随着时间的流逝销售多种类型的游戏.当我将它们绘制在一起时,看起来 seaborn 正在对数据进行标准化,但我希望我的 y 轴显示未标准化的全球销售额.为了避免这种情况,我尝试将 sns.lineplot()中的估算器设置为 None .

I am very new to seaborn and I am plotting sales over time for multiple genres of games. When I plot them together, it looks like seaborn is normalizing the data but I would like my y-axis to show the global sales value not normalized. To avoid this, I tried setting the estimator in sns.lineplot() to None.

当我将线图的估算器设置为 =None 时,我的数据突然变得全部尖峰".我首先想到可能我的数据集每年都有多个值,或者出于某种原因可能有一些 0,但事实并非如此.对于某些类型,某些年份没有数据,但是每年拥有数据的流派.

When I set the estimator to =None for my line-plot, my data suddenly gets all "spikey". I first thought that maybe my dataset had multiple values for each year or maybe some 0's in there for some reason, but this wasn't the case. For some genres there is no data for certain years, but it's getting "spikes" on genres that have data for every year.

这里没有禁用估算器...

Here it is without disabling estimator...

plt.figure(figsize=(20,10))
sns.lineplot(data=line_df,x='Year',y='Global_Sales',hue='Genre',ci=None)
plt.show()

这是我禁用它的地方,并且行显示"spikey" ...

And here is it when I disable it and the lines get "spikey"...

plt.figure(figsize=(20,10))
sns.lineplot(data=line_df,x='Year',y='Global_Sales',hue='Genre',ci=None, estimator=None)
plt.show()

推荐答案

"spikiness"是因为每个数据点都是用 estimator=None 绘制的.对于每个 x 值,每个数据点都沿着垂直线段绘制,直到最大值.然后,该行下降到下一个x值中的最小值,然后垂直击中每个数据点,直到该x值的最大值.

The "spikiness" is because each data point is plotted with estimator=None. For each x-value, each data point is plotted along the vertical segments up to the max value. Then the line drops to the lowest value in the next x-value and then goes vertically hitting each data point until the maximum value for that x-value.

如果你绘制标记,这会更明显:

This is more apparent if you plot the markers:

flights = sns.load_dataset("flights")
sns.lineplot(data=flights, x="year", y="passengers")
sns.lineplot(data=flights, x="year", y="passengers", estimator=None, marker='o')

这篇关于Seaborn中的Lineplot是"spikey".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆