|
From: Fred S. <bu...@ya...> - 2007-06-03 02:03:00
|
from visual.graph import * # import graphing features
import sys
display1 = gdisplay(x=0.0, y=0.0, width=300, height=200,
title='Cos Graph', xtitle='X', ytitle='Y',
xmax=10., xmin=-10., ymax=3., ymin=-3.,
foreground=color.black, background=color.white)
#display2 = gdisplay(x=0, y=200, width=300, height=200,
# title='Sin Graph', xtitle='X', ytitle='Y',
# xmax=10., xmin=-10., ymax=3., ymin=-3.,
# foreground=color.black, background=color.white)
graph = gcurve(gdisplay=display1,color=color.cyan) # a connected curve object
#graph2 = gcurve(gdisplay=display2,color=color.blue)
x_start= -8. # graph starting from this x value
x_end = 8. # graph ending at this x value
for x in range(x_start, x_end, 0.1):
y = cos(x) # the function we want to graph
print x,y
continue
graph.plot(pos=(x,y)) # plots a point
# y = sin(x) # the function we want to graph
# graph2.plot(pos=(x,y)) # plots a point |