Donut chart python

拟墨画扇 提交于 2019-12-04 11:10:40

From the docstring:

If *autopct* is not *None*, return the tuple (*patches*,
  *texts*, *autotexts*), where *patches* and *texts* are as
  above, and *autotexts* is a list of
  :class:`~matplotlib.text.Text` instances for the numeric
  labels.

So if you want to unpack the result of pie() using autopct you need 3 values:

kwargs = dict(colors=col, startangle=180, autopct='%1.1f%%')
outside, _, _ = ax.pie(sizes, radius=1, pctdistance=1-width/2,
                       labels=labels,**kwargs)

Or maybe it will be more robust without unpacking so it works with or without autopct:

outside = ax.pie(sizes, radius=1, pctdistance=1-width/2,
                 labels=labels,**kwargs)[0]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!