我有一个简单的Python饼图:
values = [3, 5, 12, 8]
labels = ['a', 'b', 'c', 'd']
plt.pie(values, labels)
看起来像:
我还有一本价值观词典:
dictionary = {'a': 0.31, 'b': 0.11, 'c' : 0.07, 'd': 0.12}
我想在字典中给每个片段加上相应的值。我该怎么做?我阅读了this post,它演示了如何向autopct
函数传递额外的参数,但似乎每个片段的参数必须相同,而在本例中,每个片段的参数不同
我知道你要找的是在每一块饼上都贴上标签,在dict中定义为值,对吗
比如:
希望这对你有用
相关问题 更多 >
编程相关推荐