import numpy as np
import matplotlib.pyplot as plt
x =[u'test1', u'test2', u'test3', u'test4', u'test5']# 加u 倒置
yy =[[4.08,85.7,91.67,72.22,66.67,45.83,61.67,32.50,79.17,70.00],[90.00,83.45,98.01,88.78,62.50,84.52,48.00,78.00,84.56,68.51],[45.56,24.58,76.19,53.33,80.12,87.51,51.67,68.00,52.08,77.65],[43.54,67.52,76.22,34.87,76.67,90.50,45.66,65.87,87.45,73.13],[63.54,54.27,91.47,35.41,37.87,87.43,74.49,88.50,73.62,43.73]]
y =[]for i inrange(5):
y.append(sum(yy[i])/10)# 求每段平均值
fig, ax = plt.subplots()
width =0.5# the width of the bars
ind = np.arange(len(y))# the x locations for the groups
label ='Average='+str(sum(y)/5)+'%'# label标识
ax.barh(ind, y, width, label=label, color="#87CEFA")# 颜色紫罗兰 for i, v inenumerate(y):
ax.text(v +3, i +.25,str(v), color="red", fontweight='bold')# 将值显示在柱上方
ax.set_yticks(ind + width /2)
ax.set_yticklabels(x, minor=False)
plt.title('Total/mAP')
plt.ylabel('Number of test')
plt.xlabel('mAP(%)')
plt.legend(loc="lower right")# plt.show()
plt.savefig('Total.png')