【发布时间】:2023-03-04 20:17:01
【问题描述】:
我有下图的代码。我需要为每个图表添加一个阈值。此值确实会从一组更改为另一组。
import numpy as np
import matplotlib.pyplot as plt
n_groups = 4
heuristic = (230.193, 33.96, 46, 8)
safe = (195.8, 24.83, 36, 7)
# create plot
fig, ax = plt.subplots()
index = np.arange(n_groups)
bar_width = 0.1
opacity = 0.8
rects1 = plt.bar(index, heuristic, bar_width,
marker="D",
alpha=opacity,
color='b',
label='Heuristic')
rects2 = plt.bar(index + bar_width, safe, bar_width,
alpha=opacity,
color='g',
label='SAFE')
plt.xlabel('Firmware')
plt.ylabel('nDCG')
plt.title('Matching results by firmware')
plt.xticks(index + bar_width, ('Mqtt', 'Solder', 'Iron', 'Sympetrum'))
plt.legend()
plt.tight_layout()
plt.show()
以下是它生成的图表,我使用 粉色标记 向您展示了我希望代码生成的内容。对不起,线条不直。非常感谢任何帮助。谢谢
【问题讨论】:
标签: python matplotlib graph