绘制柱状图

绘制柱状图

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 in range(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 in enumerate(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')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值