【问题标题】:how to plot a box plot of a column of a data frame in two groups in matplotlib如何在matplotlib中的两组中绘制数据框列的箱形图
【发布时间】:2017-08-29 19:19:22
【问题描述】:

我有以下数据框:

       value    total_spend margin
            1   29493.14    10203.37
            1   27551.22    19003.07
            2   22881.26    15142.68
            1   15254.77    12337.22
            1   11873.95    9424.23
            1   11382.89    8767.83
            1   11006.11    6867.29
            2   9647.16    7543.24
            2   9227.57    9227.57
            1   9077.39    6541.60
            1   8912.10    4074.26
            2   8560.05    7466.30
            1   8041.52    7425.49
            1   8007.19    5850.35
            1   7914.47    3363.42
            2   7812.48    4185.71
            2   7441.81    7341.23
            1   7388.98     6871.19

我需要从 'total_spend' 列为每组 'value' 制作一个两个箱形图。两个箱形图在同一个图中

【问题讨论】:

    标签: python pandas matplotlib dataframe boxplot


    【解决方案1】:
    df.boxplot(column='total_spend', by='value')
    

    【讨论】:

    • 问题是它没有显示一些像 max 这样的 ponts ,那些点在 75 个百分点之后
    • @sanaz 你可以用plt.ylim((min_y, max_y))设置你自己的y-limits
    猜你喜欢
    • 2017-08-04
    • 1970-01-01
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多