import matplotlib.pyplot as lt
#显示中文
lt.rcParams[‘font.sans-serif‘]=[‘SimHei‘]
lt.rcParams[‘axes.unicode_minus‘]=False
labels=‘Frogs‘,‘Hogs‘,‘Dogs‘,‘Logs‘#图标签
sizes=[10,20,30,40]#图比例
colors=[‘yellowgreen‘,‘gold‘,‘lightskyblue‘,‘lightcoral‘]#饼图分布颜色
explode=(0,0.1,0,0)#突出显示数值
lt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct=‘%1.1f%%‘,shadow=True,startangle=90)
lt.axis(‘equal‘)#显示为圆
lt.show()
原文地址:https://www.cnblogs.com/chunqing/p/9267383.html
时间: 2024-11-06 11:27:09