How do I use matplotlib autopct?

后端 未结 7 1654
野的像风
野的像风 2020-12-12 11:59

I\'d like to create a matplotlib pie chart which has the value of each wedge written on top of the wedge.

The documentation suggests I should use autopct

7条回答
  •  Happy的楠姐
    2020-12-12 12:15

    You can do:

    plt.pie(values, labels=labels, autopct=lambda p : '{:.2f}%  ({:,.0f})'.format(p,p * sum(values)/100))
    

提交回复
热议问题