4

I have only a few values on my x-axis so my error bars on my data points are competing with each other. I am not using Excel, rather Python, and would like to know how to plot only the top half or bottom half of the error bars so it's easier to read. Setting uplims = True does me no good, the bottom half of the error bars are still visible.

3
  • 2
    Have you looked at the examples? And by the way, what would half an error bar even mean? Do you imply a gaussian with a symmetric error on the other side? is the data point a lower/upper bound with some sort of uncertainty on one side?
    – Carsten
    Commented Apr 1, 2015 at 19:28
  • Yes I've checked those out - half an error bar means I'd only want the top portion or the bottom portion given my error bars are symmetrical. The data are scattered points and i only have 5 categories for the x axis so the errors are running into each other. I'd like to display only the upper or lower errors. I tried changing the uplims parameter from the default False to True and the same with the lolims parameter but either way I still get the other half of the error bar.
    – student998
    Commented Apr 1, 2015 at 19:39
  • Does this answer your question? How do I plot just the positive error bar with pyplot.bar?
    – Mr. T
    Commented Jan 3, 2021 at 8:30

1 Answer 1

10

When you pass the error bar information to the plotting function using a keyword argument such as yerr you can specify the positive and negative error bars separately as iterables that have the same length as your data. For example if you had 3 points in your scatter plot with x and y values of xdata and ydata respectively, this code would give you positive error bars for each point that had a height of 5:

ax.bar(xdata, ydata, yerr=[(0,0,0), (5,5,5)])

Conversely, if you wanted only negative error bars you could do this:

ax.bar(xdata, ydata, yerr=[(5,5,5), (0,0,0)])
1
  • 3
    You should mark this answer as the correct aster if it solved your problem
    – Jeef
    Commented Jun 8, 2017 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.