本文主要是介绍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画饼图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!