import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
x=np.arange(5)
y=[100,68,79,91,82]
err=[7,2,6,10,5]
err_attr={"elinewidth":2,"ecolor":"black","capsize":3}
plt.bar(x,y,color="c",width=0.6,yerr=err,error_kw=err_attr,tick_label=list("ABCDE"))
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
x=np.arange(5)
y=[100,68,79,91,82]
err=[7,2,6,10,5]
err_attr={"elinewidth":2,"ecolor":"black","capsize":3}
plt.barh(x,y,color="c",height=0.6,xerr=err,error_kw=err_attr,tick_label=list("ABCDE"))
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
x=np.arange(5)
y1=[100,68,79,91,82]
y2=[120,70,75,78,85]
err1=[7,2,6,10,5]
err2=[5,1,6,8,9]
err_attr={"elinewidth":2,"ecolor":"black","capsize":3}
bar_width=0.4
plt.bar(x,y1,color="#87CEEB",yerr=err1,error_kw=err_attr,width=bar_width)
plt.bar(x+bar_width,y2,color="#CD5C5C",yerr=err1,error_kw=err_attr,width=bar_width)
plt.xticks(x+bar_width/2,labels=["A","B","C","D","E"])
plt.legend([2010,2011])
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
x=np.arange(5)
y1=[100,68,79,91,82]
y2=[120,70,75,78,85]
err1=[7,2,6,10,5]
err2=[5,1,6,8,9]
err_attr={"elinewidth":2,"ecolor":"black","capsize":3}
bar_width=0.4
plt.bar(x,y1,color="#87CEEB",yerr=err1,error_kw=err_attr,width=bar_width)
plt.bar(x,y2,bottom=y1,color="#CD5C5C",yerr=err1,error_kw=err_attr,width=bar_width)
plt.xticks(x,labels=["A","B","C","D","E"])
plt.legend([2010,2011])
plt.show()