Reputation: 23
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()
Upvotes: 1
Views: 1376
Reputation: 10590
The "spikiness"/sawtooth/shark fin pattern is because each data point is plotted when 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, again, goes up vertically hitting each data point until the maximum value for that x-value. This is also mentioned in their documentation.
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')
Upvotes: 4