admin 管理员组

文章数量: 887006

matplotlib画饼图

用Python的matplotlib画饼图:
代码:

#饼图:超市主要商品本月销售量
import matplotlib.pyplot as pltplt.title('Sales of major commodities in supermarkets for this month')
labels = 'Noodles', 'Milk', 'Biscuits', 'Chocolates'
sizes = [15, 30, 45, 10]
colors = ['lawngreen', 'gold', 'red', 'deeppink']
explode = (0.1, 0, 0, 0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')
plt.show()

效果图:

本文标签: matplotlib画饼图