简体   繁体   中英

Lineplot in Seaborn is "spikey"

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 .

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()

不禁用绘图

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()

情节禁用

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')

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM