So, I calculated a confident interval for a data set with a normal distribution, and I want to build it like a mustache on a histogram of average data. I tried using the yerr parameter for plt.bar, but it calculates the standard deviation error, not a confident interval. I want the same renderings of the mustache on the barcode screen. I have confident intervals:
[(29600.87, 39367.28), (37101.74, 42849.60), (33661.12, 41470.25), (46019.20, 49577.80)]
Here is my code, I tried to supply yerr parameters with confident levels, but did not work so well.
means=[np.mean(df.iloc[x]) for x in range(len(df.index))]
CI=[st.t.interval(0.95, len(df.iloc[x])-1, loc=np.mean(df.iloc[x]), scale=st.sem(df.iloc[x])) for x in range(len(df.index))]
plt.figure()
plt.bar(x_axis, means, color='r',yerr=np.reshape(CI,(2,4))
plt.xticks(np.arange(1992,1996,1))
Here is the plot I get:

source
share