ely
ely

Reputation: 505

Change errorbar size

I have to change the size of the markers in my plot (making them bigger). How is it possible to change the width of errorbars too? I'm using matplotlib. Thanks.

plot=ax.errorbar(x,y, yerr=[y1,y2], color='red', fmt='.', markersize='10', ecolor='red',capsize=4)

Upvotes: 8

Views: 35799

Answers (2)

ttq
ttq

Reputation: 433

If you want to change the linewidth of the cap of the errorbar to say 2, then use the following:

(_, caps, _) = errorbar(x, y, yerr=[y1,y2], elinewidth=2)
for cap in caps:
     cap.set_markeredgewidth(2)

Upvotes: 2

Bonlenfum
Bonlenfum

Reputation: 20155

You can make the error bar thicker by setting the elinewidth attribute in the call to errorbar(x,y,...) errorbar documentation. But the length of the error bar is your data: you can't change the length without changing the error that it represents.

import matplotlib.pyplot as plt

# define x,y, y1,y2 here ...

plt.figure()
plt.errorbar(x,y, yerr=[y1,y2], color='red', fmt='.', markersize='10', ecolor='red',capsize=4, elinewidth=2)

Upvotes: 10

Related Questions