4

just a quick question, where I couldn't find anything helpful in the plt.errorbar documentation

I want to plot values with error bars:

import matplotlib.pyplot as plt
plt.errorbar(1, 0.25, yerr=0.1, uplims=True, lolims=True, fmt='o')
plt.show()

enter image description here

But I would like to have error bars with a simple horizontal line instead of arrows at the ends. But there is no "capmarker" or similar option in the plt.errorbar() function

1 Answer 1

9

Remove the uplims=True and lolims=True; both limits are plotted by default, without any ending arrows:

import matplotlib.pyplot as plt

plt.errorbar(1, 0.25, yerr=0.1, fmt='o')
plt.show()

enter image description here

EDIT:

Increase the capsize to add caps to the end of the error bars, and increase the capthick to make the caps thicker:

plt.errorbar(1, 0.25, yerr=0.1, fmt='o', capsize=3)

enter image description here

plt.errorbar(1, 0.25, yerr=0.1, fmt='o', capsize=3, capthick=3)

enter image description here

2
  • Thank you for your quick answer! Sorry my description was misleading. I want to have horizontal lines at the end of the colorbars instead of arrows.
    – No Body
    Mar 17, 2020 at 7:04
  • 2
    Great answer! Thanks @BigBen, this should be better explained/showcased in the documentation Jan 27, 2021 at 2:22

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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