2

Is is possible to remove the caps/ticks at the extremal points of the errorbars generated with the errorbar() command? For example, the seaborn module hides them by making them very thin but does not remove them entirely.

lsrggr
  • 399
  • 6
  • 12

1 Answers1

4

Yes it can be done by setting the capsize keyword to 0.

Here is an example:

import matplotlib.pyplot as plt
import numpy as np
import random

x = np.linspace(1,2,10)
y = np.linspace(2,3,10)
err = [random.uniform(0,1) for i in range(10)]

plt.errorbar(x, y,
       yerr=err,
       marker='o',
       color='k',
       ecolor='k',
       markerfacecolor='g',
       capsize=0,          #Here I have set capsize = 0 
       linestyle='None')
plt.show()

This produces an image like this:

enter image description here

Whereas when we set capsize = 5 or any other quantity, the size of the cap varies accordingly.

Here is what it would look like.

enter image description here

Srivatsan
  • 9,225
  • 13
  • 58
  • 83
  • Thank you! I actually tried this at one point, too. But I think at that time it was overwritten by the seaborn library. By accident, do you know if there is a way to set this option permanently? – lsrggr May 28 '15 at 08:40
  • @user3118583: As far as I know, you will have to specify the `capsize` everytime you plot. I don't think there is a permanent option – Srivatsan May 28 '15 at 09:05