【问题标题】:Multiple boxplot with seaborn, but not within the same frame带有seaborn的多个箱线图,但不在同一框架内
【发布时间】:2020-09-20 19:08:03
【问题描述】:

如果是熊猫箱线图,我们可以使用:

for column in df:
    plt.figure()
    df.boxplot([column])

使用seaborn 可以等效地完成什么,我想绘制多个箱线图,但不是在同一帧中,而是在循环中单独为每一列绘制

【问题讨论】:

    标签: python dataframe matplotlib seaborn boxplot


    【解决方案1】:

    您可以将Axes 对象传递给 sns.boxplot:

    for column in df:
        fig, ax = plt.subplots()
        sns.boxplot(df[column], ax=ax)
    

    【讨论】:

    • 感谢@Stef,可以作为垂直图,而不是水平图
    • 是的,使用y=df[column] 而不是x=df[column],它只是df[column] 的缩写
    猜你喜欢
    • 1970-01-01
    • 2018-09-08
    • 2023-02-24
    • 2023-03-10
    • 2017-11-17
    • 2021-11-27
    • 2023-03-29
    • 1970-01-01
    • 2021-04-18
    相关资源
    最近更新 更多