errorbar() (Matplotlib)
ax.errorbar() draws a line or scatter plot with error bars showing the uncertainty around each point. It is the standard chart for plotting measured data with its standard deviation or confidence interval.
Matplotlib
Pass yerr (and/or xerr) alongside your x and y data, and Matplotlib draws a bar through each point spanning the given uncertainty. yerr can be a single number applied to all points, an array for per-point errors, or a 2-row array for asymmetric lower/upper bounds.
The capsize argument adds little caps to the ends of the bars to make them clearer, and fmt controls the marker and line style of the central points (fmt='o' for points only, no connecting line). It is the go-to for scientific plots where showing variability is as important as showing the mean.
errorbar returns an ErrorbarContainer bundling the data line, the caps, and the bar lines. For a shaded uncertainty band instead of discrete bars, fill_between is the common alternative.
Syntax
ax.errorbar(x, y, yerr=None, xerr=None, fmt='', capsize=0)Examples
Python
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
eb = ax.errorbar([1, 2], [3, 4], yerr=0.5)
print(type(eb).__name__)Output:
ErrorbarContainer