【问题标题】:seaborn how do i create a box plot of only particular attributes in a dataframeseaborn 如何在数据框中创建仅包含特定属性的箱线图
【发布时间】:2016-11-26 08:11:00
【问题描述】:

我想创建两个箱线图,通过根据其比例拆分属性来可视化我的数据中的不同属性。我目前有这个

显示属性分布的箱线图

sns.boxplot(data=df)

box plot with all attributes included

我希望它像下面的图像一样,根据它们的比例在不同的箱形图中具有属性,但在每个箱形图下方都有属性标签(不是当前整数)。

显示属性分布的箱线图

sns.boxplot(data=[df['mi'],df['steps'],df['Standing time'],df['lying time']])

box plot by scale 1

【问题讨论】:

    标签: pandas boxplot seaborn


    【解决方案1】:

    您可以通过使用列名列表索引来对 pandas DataFrame 进行子集化

    sns.boxplot(data=df[['mi', 'steps', 'Standing time', 'lying time']])
    

    【讨论】:

    • @xjackx 如果解决方案对您有用,请“接受”答案,将问题标记为已解决
    • 嗨@mwaskom 你能帮忙解决这个stackoverflow.com/questions/38595612/… 我想从你的一个答案中更改一些功能,但我想不通。谢谢!
    猜你喜欢
    • 2021-10-07
    • 2019-04-05
    • 2021-12-10
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 2019-02-18
    • 2019-02-27
    • 2020-07-01
    相关资源
    最近更新 更多