8

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)
abcd
  • 10,215
  • 15
  • 51
  • 85
ely
  • 495
  • 2
  • 9
  • 12

2 Answers2

9

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)
Bonlenfum
  • 19,101
  • 2
  • 53
  • 56
  • Thanks Bonlenfum. I know that the length depends on my data, but is there any possibility to enlarge both the points and the error bars? – ely Apr 15 '13 at 09:12
  • @ely i know you asked this years ago, but i see that bonlenfum didn't really answer your question. `markersize` sets the sizes of the markers (what you call the "points," i believe) and `elinewidth` sets the width of the errorbars. – abcd Aug 18 '16 at 02:09
  • 1
    If using `plt.bar()` or other types which can indirectly draw error bars, one can use: `error_kw={'elinewidth': 2}` – gaborous Sep 13 '17 at 23:33
2

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)
ttq
  • 383
  • 3
  • 7
  • 1
    so `capsize` sets the length of the caps, and `set_markeredgewidth` sets the width. – abcd Aug 18 '16 at 02:00