【问题标题】:Matplotlib Histogram looks incorrect (only one bin)Matplotlib 直方图看起来不正确(只有一个 bin)
【发布时间】:2020-10-30 06:14:58
【问题描述】:

我正在尝试创建几个子图,但其中一半看起来很奇怪

似乎 y 轴值已关闭。有谁知道问题出在哪里?

fig, (ax1, ax2, ax3, ax4,ax5) = plt.subplots(1,5, figsize = (16,4))
ax1.hist(df['AVG_TIME_BETWEEN_PURCHASES'], edgecolor = 'white', align = 'mid', bins=20)
ax1.set_xlabel('Abstand zw. Käufen')
ax1.set_ylabel('Count')
ax2.hist(df['DAYS_SINCE_LAST_ORDER'], edgecolor = 'white', align = 'mid', bins=20)
ax2.set_xlabel('vergangene Tage')
ax3.hist(df['CUSTOMER_LIFETIME_VALUE'], edgecolor = 'white')
ax3.set_xlabel('Total Revenue')
ax4.hist(df['AVERAGE_ORDER_VALUE'], edgecolor = 'white', align = 'mid')
ax4.set_xlabel('Avg Revenue')
ax5.hist(df['CATEGORY_REVENUE_PARFUM'], edgecolor = 'white', align = 'mid')
ax5.set_xlabel('Revenue Parfum')
plt.tight_layout()
plt.show()

【问题讨论】:

    标签: python matplotlib histogram subplot


    【解决方案1】:

    如果不查看更多代码和相关数据,很难判断,但我注意到 ax3ax4ax5 在其方法调用中没有指定 bins=20

    这些似乎也是看起来不正确的图表。

    您是否尝试过添加该属性?

    【讨论】:

      【解决方案2】:

      在没有看到您的数据的情况下,数据集中可能存在一些异常值。我会检查CUSTOMER_LIFETIME_VALUEAVERAGE_ORDER_VALUECATEGORY_REVENUE_PARFUM 中的最大值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-15
        • 1970-01-01
        • 2014-03-15
        • 2013-04-03
        • 2016-10-14
        • 2021-01-25
        • 2011-10-22
        • 2016-12-30
        相关资源
        最近更新 更多