使用matplotlib画y=sin(x)

3352阅读 0评论2008-05-22 libin1983
分类:Python/Ruby

大学时,我们使用Matlab画数学图形.
matplotlib 模块也提供了类似的功能.
matplotlib下载地址: 
matplotlib 依赖 numpy.

下面是我画图的代码.

#!/usr/bin/env python
#coding=GBK
import pylab
import math

a = range(0, 360+1) #度数
x = map(lambda x:math.pi*x/180.0, a)
#y = map(lambda x:math.sin(x*math.pi/180.0), a)
y = map(lambda x:math.sin(x), x)
pylab.plot(x,y)

pylab.title('y = sin(x)')
pylab.xlabel('x')
pylab.ylabel('y')

pylab.show()



上一篇:C 里sizeof原來是單目運算符
下一篇:lua, python, JavaScript實現斐波拉菲求解