The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Use plt.errorbar(x, y, yerr=...) to add vertical uncertainty intervals to a Matplotlib plot, and xerr=... for horizontal intervals. Supply error magnitudes as a scalar or one value per point for symmetric bars, or as a two-row array for different lower and upper magnitudes. The examples below use the official Matplotlib 3.11.0 API.
Plot basic vertical error bars
Pass the data coordinates as x and y, then give yerr the vertical error magnitude or magnitudes. This example draws a marker at each point and adds caps to the error bars:
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2.0, 2.8, 4.2]
yerr = [0.2, 0.35, 0.25]
fig, ax = plt.subplots()
ax.errorbar(x, y, yerr=yerr, fmt='o', capsize=3)
ax.set_xlabel('x')
ax.set_ylabel('y')
plt.show()
The equivalent pyplot call is plt.errorbar(x, y, yerr=yerr, fmt='o', capsize=3). The object-oriented form, ax.errorbar(...), adds the plot to a particular axes.
Choose the error input shape
For either xerr or yerr, the error values are magnitudes, not signed offsets. Every value must be greater than or equal to zero. The official Matplotlib 3.11.0 errorbar reference accepts these forms:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problems#1 Best Overall
| Input | Meaning | Example |
|---|---|---|
| Scalar | The same symmetric error for every data point. | yerr=0.2 |
Array of shape (N,) |
A symmetric error for each of N data points. | yerr=[0.2, 0.35, 0.25] |
Array of shape (2, N) |
Different lower and upper error magnitudes at each point. Row 0 contains lower errors; row 1 contains upper errors. | yerr=[[0.1, 0.2, 0.15], [0.3, 0.4, 0.25]] |
Represent asymmetric errors
Put the lower magnitudes in the first row and the upper magnitudes in the second. For example:
lower_errors = [0.1, 0.2, 0.15]
upper_errors = [0.3, 0.4, 0.25]
ax.errorbar(x, y, yerr=[lower_errors, upper_errors], fmt='o', capsize=3)
Do not make the lower row negative to indicate direction. Matplotlib interprets the rows by position and requires nonnegative magnitudes.
Rank #2
Add horizontal, vertical, or combined intervals
yerr draws vertical intervals and xerr draws horizontal intervals. Supply both when each point needs uncertainty in both coordinates:
ax.errorbar(x, y, xerr=[0.1, 0.2, 0.15], yerr=[0.2, 0.35, 0.25], fmt='o', capsize=3)
Each error input should match the corresponding coordinate data: a scalar applies the same magnitude throughout, while arrays specify per-point magnitudes.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchStyle the bars and markers
Use fmt to choose how the data points are shown, and use the error-bar options to control their appearance. The defaults and available parameters are described in the API reference.
fmt='o'uses circle markers; other Matplotlib format strings can select a different marker or line style.fmt='none'(case-insensitive) draws only the error bars, without the data markers or connecting line.ecolorsets the error-line color. If omitted, the data line color is used.elinewidthandelinestyleset the error-line width and style.capsizesets cap length in points. Its default followsrcParams['errorbar.capsize'], which the reference documents as0.0; set it explicitly when you want visible caps.capthickcontrols cap thickness, but legacymewormarkeredgewidthsettings override it for backward compatibility.barsabove=Trueplaces error bars above the plot symbols; the default is below them.
Thin bars when points overlap
Set errorevery=N to draw error bars at every Nth point. Use errorevery=(start, N) to choose a starting index and then draw every Nth bar. The data series itself remains present; only the error bars are thinned. This can help when intervals overlap or multiple series share x values.
Show one-sided limits
For censored values or other one-sided bounds, use lolims, uplims, xlolims, or xuplims to mark lower or upper limits for y or x. These flags add caret-style limit indicators rather than treating every value as an ordinary two-sided interval.
The names can be counterintuitive: lolims=True means the plotted y value is a lower limit of the true value, so Matplotlib draws an upward-pointing arrow. If the relevant axis is inverted, set its limits before calling errorbar(), as noted in the official reference.
Recommended Free Tools
Best Value
Keep the statistical meaning explicit
errorbar() draws the magnitudes you supply; it does not determine whether they represent standard deviation, standard error, a confidence interval, or another quantity. State the quantity and how it was calculated in the surrounding text or legend. The same visual form can represent different kinds of uncertainty, so the label is part of making the plot interpretable.
Use the returned container or check version-specific behavior
The call returns an ErrorbarContainer containing the data line (Line2D), cap lines (Line2D objects), and error-bar line collections (LineCollection). That return value can be useful if later code needs to inspect or style the plotted components.
For polar plots, the 3.11.0 reference says caps and error lines are drawn in polar coordinates, a behavior introduced in Matplotlib 3.7. If a polar plot behaves unexpectedly, check the documentation for the Matplotlib version actually installed.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




