欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

matplotlib 使用

程序员文章站 2022-03-01 22:16:57
...

matplotlib

Matplotlib是一个Python 2D绘图库,可以生成各种硬拷贝格式和跨平台交互式环境的出版物质量数据。Matplotlib可用于Python脚本,Python和IPython shell,Jupyter笔记本,Web应用程序服务器和四个图形用户界面工具包。

使用 demo:线图

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some ylabel')
plt.show()
复制代码

demo2:饼图

>>> import matplotlib.pyplot as plt
>>> labels = 'a','b','c','d'
>>> explode=(0,0,0.2,0)
>>> explode=(0.1,0,0.2,0)
>>> fig1,ax1=plt.subplots()
>>> sizes=[15,30,45,10]
>>> ax1.pie(sizes,explode=explode,labels=labels,autopct='%1.1f%%',shadow=True,startangle=90)
>>> ax1.axis('equal')
>>> plt.show()
复制代码

参考

转载于:https://juejin.im/post/5d02034a51882559f0402581

上一篇: matplotlib使用

下一篇: matplotlib使用