背景
有两组数据,用柱状图表示出两组数据之间的差异
代码
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()