Python:使用sns.distplot()混淆绘图结果

时间:2019-09-15 05:56:46

标签: python

enter image description here

kde分布与直方图不太吻合。有人知道如何解决这个问题吗?

fig, ax = plt.subplots(1, 2, figsize = (18, 6))
hist_kws = {'histtype': 'bar', 'edgecolor':'black', 'alpha': 0.2}

sns.distplot(df[df['converted'] == 1]['total_pages_visited'], ax = ax[0], label = 'converted distribution', 
             bins = np.arange(df[df['converted'] == 1]['total_pages_visited'].min(), 
                              df[df['converted'] == 1]['total_pages_visited'].max() + 1), 
             hist_kws = hist_kws)
sns.distplot(df['total_pages_visited'], ax = ax[0], label = 'pages visited distribution', 
             bins = np.arange(df['total_pages_visited'].min(), df['total_pages_visited'].max() + 1),
             hist_kws = hist_kws)
ax[0].set_title('distribution of total pages visited', fontsize = 16)
ax[0].set_xlabel('total pages visited')
ax[0].legend()

0 个答案:

没有答案