Reputation: 37
I have a code and I want to see output using vpython. following is the code
#!/usr/local/bin/ python3
from vpython import *
Plot1 = gcurve ( color = color . white )
for x in arange(0., 8.1, 0.1):
Plot1.plot( pos = (x, 5.*cos(2.*x)*exp(-0.4*x)) )
graph1 = gdisplay ( width =600, height =450 ,\
title="Visual 2D Plot", xtitle="x", ytitle="f(x)",\
foreground = color . black , background = color . white )
Plot2 = gdots ( color = color . black )
for x in arange( -5., +5, 0.1 ):
Plot2.plot(pos = (x, cos(x)))
it is giving this error, however, it is showing a box of a white background with no plot in it. Error: name 'gdisplay' is not defined
how can I define g display?
Upvotes: 2
Views: 500
Reputation: 992
With VPython 7 the name is "graph", not gdisplay. And "from vpython import *" includes the graph object.
Upvotes: 0
Reputation: 6090
You need to import the visual module of VPython:
from visual.graph import *
Upvotes: 1