【问题标题】:Turn off error bars in Seaborn Bar Plot关闭 Seaborn 条形图中的误差线
【发布时间】:2017-02-26 13:36:31
【问题描述】:

我在 matplotlib 中使用 GridSpec 创建一个包含 9 个子图的页面。其中一个子图是使用以下代码创建的 Seaborn 条形图:

import seaborn as sns
sns.barplot(x=df['Time'], y=df['Volume_Count'], ax=ax7)

有没有办法关闭条形图的垂直误差线?如果没有,是否可以减少条的水平宽度?

谢谢!

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    @Diziet Asahi 的完整示例

    import numpy as np
    import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    
    df = sns.load_dataset('titanic')
    
    # Usual case
    sns.barplot(x='class',y='age',hue='survived',data=df)
    
    # No error bars (ci=None)
    sns.barplot(x='class',y='age',hue='survived',data=df,ci=None)
    

    通常情况下的输出

    输出无误差线

    【讨论】:

      【解决方案2】:

      您是否尝试过 ci 参数?根据the documentation

      ci : 浮动或无,可选 围绕估计值绘制的置信区间大小。如果 None,不会执行引导,并且会出现错误栏 不被绘制。

      sns.barplot(x=df['Time'], y=df['Volume_Count'], ax=ax7, ci=None)
      

      【讨论】:

        猜你喜欢
        • 2020-12-23
        • 2023-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多