Change the error bar thickness in Matplotlib

Python

Matplotlib

Errorbar

Change thickness

Luc B.

Python

Matplotlib

Error Bar

Depending on the look and feel of a plot, it's sometimes necessary to change the thickness of error bars to make them more or less visible.

Code Example

To change the width of your error bars, pass a numerical value as the elinewidth parameter to plt.errorbar(). If you have caps on your error bars, utilize the capthick parameter as well.

import matplotlib.pyplot as plt

x_values = [20, 16, 12, 19, 18, 22, 14]
y_values = [1, 0.77, 0.67, 0.85, 0.78, 1.05, 0.63]
y_err = [0.3, 0.2, 0.4, 0.5, 0.3, 0.2, 0.3]

# Change the error bar thickness here
plt.errorbar(x_values, y_values, yerr=y_err,
             elinewidth=5, capthick=5, capsize=10, fmt=" ")

plt.show()

png