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!
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.
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.
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.
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With