How to interpret Seaborn distplot's axes

2019-07-19 03:04发布

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: enter image description here

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.

2条回答
戒情不戒烟
2楼-- · 2019-07-19 03:45

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)

enter image description here

查看更多
霸刀☆藐视天下
3楼-- · 2019-07-19 03:47

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.

查看更多
登录 后发表回答