我在字典中有以下数据,想用标签('AT','BT','CT','DT','ET')绘制条形图。如果只考虑小数点后的3位数,也可以。
{0:0,1:19.091883092036781,2:35.317606562921746,3:22.122563913375465,4:37.961028320110699,5:36.541670802198659}
使用matplotlib尝试以下操作:
import matplotlib.pyplot as plt
data = {0: 0, 1: 19.091883092036781, 2: 35.317606562921746, 3: 22.122563913375465, 4: 37.961028320110699, 5: 36.541670802198659}
bar_width = 0.8
plt.bar([x for x in data], [data[x] for x in data], bar_width)
plt.xticks([x + bar_width/2 for x in data], (' ', 'AT','BT','CT','DT','ET'))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句