2024-10-01 13:29:29 发布
网友
在plotule中如何使用键值而不是键值
tuple=(1,2,3,4) rects1 = ax.bar(ind, tuple, width, color='r')
但我想这样做
我猜你想做这样的事
rects1 = ax.bar(ind, (dic[k] for k in ind), ...)
这样在索引和字典中的值之间有一个映射。在
试试这个:
rects1 = ax.bar(ind, (dic[key] for key in dic.keys()), width, color='r')
甚至:
根据Amars的评论,如果dict是这样的:
dic={'a':(1,2),'b':(2,2),'c':(3,2)}
并且您只想使用值(1, 2, 3),您需要创建一个有序集:
(1, 2, 3)
rects1 = ax.bar(ind, sorted(set(dic.values())), width, color='r')
我猜你想做这样的事
这样在索引和字典中的值之间有一个映射。在
试试这个:
甚至:
^{pr2}$根据Amars的评论,如果dict是这样的:
并且您只想使用值
(1, 2, 3)
,您需要创建一个有序集:相关问题 更多 >
编程相关推荐