python画图+error bar+95%置信区间

#!/usr/bin/env python
# a bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import t


RLMeans = [84.32, 76.66, 67.68, 58.88, 55, 52.14]
RLStd = [1, 1.2, 1.3, 1.1, 1, 1.2]

N = 6

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

dof = N - 1         # degrees of freedom
alpha = 1.0 - 0.95

temp_conf1 = t.ppf(1-alpha/2., dof) * np.sqrt(1.+1./N)

conf_interval_RL = [temp_conf1 * i for i in RLStd]


fig, ax = plt.subplots()
rects1 = ax.bar(ind, RLMeans, width, yerr=conf_interval_RL)

MAMeans = [83.6, 68.2, 59.87, 51.07, 43.64, 36.32]
MAStd = [0.3, 0.8, 0.5, 0.4, 0.7, 0.6]

temp_conf1 = t.ppf(1-alpha/2., dof) * np.sqrt(1.+1./N)
conf_interval_MA = [temp_conf1 * i for i in MAStd]
rects2 = ax.bar(ind + width, MAMeans, width, yerr=conf_interval_MA)

# add some text for labels, title and axes ticks
ax.set_ylabel('escape rate(%)', fontsize=15)
ax.set_xlabel('noise', fontsize=15)
ax.set_xticks(ind + width/2.)
ax.set_xticklabels(('0', '1', '2', '3', '4', '5'))
ax.set_ylim(30,100)
ax.legend((rects1[0], rects2[0]), ('RL', 'MA'), fontsize=15)

def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
                '%d' % int(height),
                ha='center', va='bottom')

autolabel(rects1)
autolabel(rects2)

plt.show()
python画图+error bar+95%置信区间