matplotlib画柱状对比图

背景

有两组数据,用柱状图表示出两组数据之间的差异

代码

import numpy as np
from matplotlib import pyplot as plt
'''
柱形对比图
共有11组数据
'''
size = 11
## 两组数据
l_count_last = [24, 34, 1, 36, 7, 48, 39, 140, 321, 1476, 3841]
l_count_new = [30, 29, 3, 30, 8, 49, 53, 217, 820, 2873, 2438]
x = np.arange(size)
# 有a/b两种类型的数据,n设置为2
total_width, n = 0.6, 2
# 每种类型的柱状图宽度
width = total_width / n
plt.bar(x, l_count_last, width=width, label="model_1020", color='#9ACD32')#
plt.bar(x + width, l_count_new, width=width, label="model_1208", color='#aa66cc')
## x轴刻度名称
xticks = ['miss', '0.0~0.1', '0.1~0.2', '0.2~0.3', '0.3~0.4', '0.4~0.5', '0.5~0.6', '0.6~0.7', '0.7~0.8', '0.8~0.9',
          '0.9~1.0']
xline = [i for i in np.arange(11)]
plt.xticks(xline, xticks)

plt.legend(loc='upper right')
# plt.xlabel("Threshold",fontname="Times New Roman")
plt.xlabel("BBox iou")
plt.ylabel("Number of samples")
plt.title('model comparision')
# 显示柱状图
plt.show()

效果

在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值