且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python matplotlib 绘图

更新时间:2022-09-13 12:55:25

阅读目录

回到顶部

饼图

python matplotlib 绘图
import matplotlib.pyplot as plt

# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90)

# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')


plt.savefig('D:\\pie.png')
plt.show()
python matplotlib 绘图

 结果

python matplotlib 绘图






本文转自jihite博客园博客,原文链接:http://www.cnblogs.com/kaituorensheng/p/5668636.html,如需转载请自行联系原作者