Python Pandas:如何使饼图具有独特的颜色

时间:2018-11-24 18:09:01

标签: python pandas charts plotly

我创建了一个包含15个值的饼图。它可以正确显示,除了某些颜色是重复的以外,这使得很难看到条形图链接了什么值。请参阅下面的当前饼图。

enter image description here

饼图使用的代码是:

import plotly.plotly as py
import plotly.graph_objs as go


plt.figure(figsize=(7,5))
labels = [ 'Anti-social behaviour', 'Bicycle theft', 'Burglary','Criminal damage and arson', 'Drugs', 'Other crime', 'Other theft', 'Possession of weapons', 'Public order', 'Robbery',
          'Shoplifting', 'Theft from the person', 'Vehicle crime', 'Violence and sexual offences']


sizes = summergroup **<the df**
patches, texts = plt.pie(sizes)
plt.legend(patches, labels, bbox_to_anchor=(0.93,0.93), loc="upper left")



plt.axis('equal')
plt.tight_layout()
plt.show()

任何人都可以阐明如何使条形图上的所有颜色唯一吗?

0 个答案:

没有答案