Barplot with Error Bars using Seaborn


If you have aggregated values on your barplot (like the mean value of several data points), it may be better to add error bars. This post shows how to add error bars on a barplot using seaborn.

If you are using aggregated values in a barplot, error bars will give you a general idea of how precise a measurement is. 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. ci parameter controls the size of confidence intervals to draw around estimated values (Note that if you want to draw the standard deviation of the observations, you should pass ci="sd").

Additionally, you can change the width of the caps on error bars with the capsize parameter.

# import libraries
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

# load dataset
tips = sns.load_dataset("tips")

# Set the figure size
plt.figure(figsize=(14, 8))

# plot a bar chart
ax = sns.barplot(x="day", y="total_bill", data=tips, estimator=np.mean, ci=85, capsize=.2, color='lightblue')

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Contact & Edit

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D