pylab

来源:互联网 发布:nba2konline强退软件 编辑:程序博客网 时间:2024/05/13 16:52
pylab模块真的很好用。
下面的测试代码,一运行就知道用法了。真的好简单

from pylab import *
import random
##plot([1,2,3,4])
####plot([5,6,7,8])
##plot([1,2,3,4], [1,4,9,16])
####figure()
##plot([1,2,3,4], [1,4,9,16], 'ro')
##axis([0, 6, 0, 20])
##title('Earnings')
##xlabel('Days')
##ylabel('Dollars')
##figure()
##xAxis = array([1,2,3,4])
##print (xAxis)
##test = arange(1,5)
##print (test)
##print (test == xAxis)
##yAxis = xAxis**3
##plot(xAxis, yAxis, 'ro')
##figure()
##vals = []
##dieVals = [1,2,3,4,5,6]
##for i in range(10000):
##   vals.append(random.choice(dieVals)+random.choice(dieVals))
##hist(vals, bins=11)
x=arange(0,20,.2)
y=[sin(b) for b in x]
plot(x,y)

show()
最下面这个是做函数图像的,这是正弦函数
pylab

arange()这个函数是numpy的,python的range不支持float
pylab
pylab
这一张是什么函数啊?其实我有曲线瘾,高中时养成的。
x=arange(-10,10,.2)
y=[b*sin(b) for b in x]
==========================================================
x=arange(-10,30,.2)
y=[b**sin(b) for b in x]
pylab


0 0
原创粉丝点击