Search code examples
pythonmatplotliberrorbar

Arrow styles for upper limits and error bars


How do I change the arrow style when making upper limits or error bars? I want to plot a data set of upper limits and have the arrows not filled.

My code so far looks like this:

testdata = np.random.random(300)
plt.errorbar(np.arange(300), testdata, xerr=None, yerr=0.04, uplims=True, fmt='_', capsize=3)

And returns this plot:

enter image description here

How can I get the following kind of arrows?

enter image description here


Solution

  • You can try using a combination of elinewidth and set_fillstyle

    testdata = np.random.random(300)
    fig, axs = plt.subplots()
    plot, caps, bars = plt.errorbar(np.arange(300), testdata, xerr=None, yerr=0.04, uplims=True, fmt='_', capsize=2, elinewidth=0.5)
    caps[0].set_fillstyle('none')