According to matplotlib documentation, the method matplotlib.pyplot.bar() returns a
"container with all the bars and optionally errorbars"
(https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.bar.html)
I have created a bar plot with the following code:
x = plt.bar(spacing, medians, yerr=yerr, capsize=20, width=0.5, tick_label = x_labels, edgecolor= "black")
which creates the following bar chart:
However, the variable x only contains the bars, not the errorbars as the documentation says it should.
Any ideas how I can get at the error bars?
You should be able to access them using:
x.errorbar.get_children()
To get the line segments, you can use get_segments()
on the LineCollection
:
x.errorbar.get_children()[0].get_segments()