Matplotlib是一个非常有用的Python绘图库,它和NumPy结合的很好,但本身是一个单独的开源项目。
*Matplotlib有一些功能函数可以从雅虎财经频道下载并处理数据。
安装:推荐安装Anaconda,其包含Matplotlib
示例图库:http://matplotlib.org/gallery/index.html
“helloworld”: 画一个简单的图形:
#coding:utf-8
'''
__tile__=''
__auther__='Leon'
__mtime__='2017/12/6'
'''
import matplotlib.pyplot as plt
a = [1,2,3,4]
b = [6,6.5,7,9]
#plot导入x/y轴采样点
plt.plot(a,b)
#保存图片
plt.savefig('hello.jpg')
#显示所绘图形
#plt.show()
#y=x^2
x = range(-100,100)
y = [item**2 for item in x]
plt.plot(x,y)
plt.savefig('result.jpg')
#plt.show()