Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change errorbar size

Tags:

matplotlib

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)
like image 673
ely Avatar asked Apr 15 '13 08:04

ely


2 Answers

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)
like image 174
Bonlenfum Avatar answered Nov 07 '22 05:11

Bonlenfum


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)
like image 32
ttq Avatar answered Nov 07 '22 05:11

ttq