Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off error bars in Seaborn Bar Plot

I'm using GridSpec in matplotlib to create a page that has 9 subplots. One of the subplots is a Seaborn bar plot created with the following code:

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

Is there a way to turn off the vertical error bars of the bar plot? If not, is it possible to reduce the horizontal width of the bars?

Thanks!

like image 848
equanimity Avatar asked Oct 17 '16 14:10

equanimity


People also ask

How do I get rid of error bars in Seaborn barplot?

This example shows how to add error bars into your chart. By default, the barplot() function draws error bars in the plot with 95% confidence interval. You can remove error bars by passing ci=None argument.

What is black line in SNS barplot?

The bar is the confidence interval for the variable as the library describes, i.e. it's interval where the 100 % (in my case ci=100) of your variable lies in, which is estimated by bootstrapping method (in statistics). Follow this answer to receive notifications.

What is error bars in barplot?

Error bars give a general idea of how precise a measurement is, or conversely, how far from the reported value the true (error free) value might be. If the value displayed on your barplot is the result of an aggregation (like the mean value of several data points), you may want to display error bars.


Video Answer


2 Answers

Have you tried the ci argument? According to the documentation:

ci : float or None, optional Size of confidence intervals to draw around estimated values. If None, no bootstrapping will be performed, and error bars will not be drawn.

sns.barplot(x=df['Time'], y=df['Volume_Count'], ax=ax7, ci=None)
like image 100
Diziet Asahi Avatar answered Oct 18 '22 18:10

Diziet Asahi


Complete example for @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)

Output for Usual case

enter image description here

Output No error bars

enter image description here

like image 8
BhishanPoudel Avatar answered Oct 18 '22 18:10

BhishanPoudel