How to interpret Seaborn distplot's axes

2019-07-19 03:22发布

问题:

Snippet:

plt.figure(figsize=(10,5))
plt.xticks(np.arange(0, 11, 1))
sns.distplot([1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10], kde=False)

Output:

What is the x-axis and the y-axis?

I thought x represents the boundary of each bin and y is the number of occurrence that falls into the bin, but the values on the y-axis does not seem correct


Update: thanks to @tryptofan, if the following command is execute, the same graph is produced:

sns.distplot([1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10], kde=False, bins=3)

The fact that Seaborn does not return any bin info + the custom xtick I did plt.xticks(np.arange(0, 11, 1)) made this chart really confusing.

回答1:

The intervalle unit in the distplot of your output is 3, so you count 6 occurrences of values between 1 and 4, 8 occurrences of values between 4 and 7, and 6 occurrences of values between 7 and 10.



回答2:

Your are trying to shove 10 bins into 9

plt.figure(figsize=(10,5))
plt.xticks(np.arange(0, 11, 1))
sns.distplot([1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10], kde=False, bins=10)