File: plot.py

package info (click to toggle)
swig 1.1p5-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 9,448 kB
  • ctags: 5,025
  • sloc: cpp: 21,599; ansic: 13,333; yacc: 3,297; python: 2,794; makefile: 2,197; perl: 1,984; tcl: 1,583; sh: 736; lisp: 201; objc: 143
file content (44 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Now use our plotting widget

import posix
from plotwidget import *
from math import *

def func1(x):
	return 0.5*sin(x)+0.25*sin(2*x)+0.125*cos(4*x)

print "Making plot1.gif..."
# Make a widget and set callback
w = PlotWidget(500,500,-10,-2,10,2)
w.set_pymethod(func1)
w.plot()
f = open("plot1.gif","w")
w.save(f)
f.close()

# Comment this line out if you don't have xv
posix.system("xv plot1.gif &")

# Make another plot

print "Making plot2.gif..."
w1 = PlotWidget(500,500,-4,-1,4,16)
w1.set_pymethod(lambda x: x*x)
w1.plot()
f = open("plot2.gif","w")
w1.save(f)
f.close()

posix.system("xv plot2.gif &")

# Make yet another plot

print "Making plot3.gif..."
w2 = PlotWidget(500,500,-7,-1.5,7,1.5)
w2.set_pymethod(sin)
w2.plot()
f = open("plot3.gif","w")
w2.save(f)
f.close()

posix.system("xv plot3.gif &")