简体   繁体   English

使用 python 在 output 中没有绘制图表

[英]No graph plotted in output using python

I have a code and I want to see output using vpython.我有一个代码,我想使用 vpython 查看 output。 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.它给出了这个错误,但是,它显示了一个白色背景框,其中没有 plot。 Error: name 'gdisplay' is not defined错误:未定义名称“gdisplay”

how can I define g display?如何定义 g 显示?

You need to import the visual module of VPython:你需要导入 VPython 的可视化模块:

from visual.graph import *

With VPython 7 the name is "graph", not gdisplay.在 VPython 7 中,名称是“graph”,而不是 gdisplay。 And "from vpython import *" includes the graph object.而“from vpython import *”包括图 object。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM