Dynamic graph in VPython/Jupyter

101 views
Skip to first unread message

Maarten Hoogerland

unread,
Apr 26, 2017, 5:51:04 PM4/26/17
to VPython-users
Hello

I want to display an animation of a graph in VPython/Jupyter. I see I can do this in Glowscript (use a "series" and delete it before redoing the plot), but in Jupyter there is no "series" and a "gcurve" has no member function "delete"

Previously in classic vpython is I generated a "curve" and modified the coordinates of all the points on the curve to make an animation. Now in Jupyter the "curve" object has no coordinates that I can access after making the curve?

Any ideas how I can make this work?

Thanks,

Maarten  

Bruce Sherwood

unread,
Apr 26, 2017, 10:23:21 PM4/26/17
to VPython-users
Thanks for reporting that the delete method for gcurve, gdots, gvbars, and ghbars is broken in Juptyer VPython. You're right that the series capabilities of the Flot graphing package should be documented and implemented in Jupyter VPython.

Also, in Jupyter VPython the modify method for curves is broken, which I hadn't realized. However, you can use the splice method to change points in a curve. See the documentation at 


I also corrected some mistakes in the curve documentation having to do with the dictionary format of curve points.

Maarten Hoogerland

unread,
Apr 27, 2017, 2:43:50 AM4/27/17
to VPython-users
Thanks for that Bruce! Splicing does seem to work. Splicing point by point is too slow, but splicing the whole curve (apart from the last point?) is OK. See this snippet:

from vpython import *
scene=canvas()
c=curve()
for i in range(100):
    x=i/10-5
    y=sin(i/10)
    z=0
    c.append(pos=vector(x,y,z))
#sleep(1)
j=0
while j<10:
    rate(2)
    j=j+1
    print(j)
    t=[]
    for i in range(99):
        t.append(vector(i/10-5,sin(j*i/10.0),0.0))
    c.splice(0,99,t)

As soon as I change 99 to 100 it complains that it is deleting too much. 

Thanks again for looking at this!

Bruce Sherwood

unread,
Apr 27, 2017, 8:24:50 AM4/27/17
to VPython-users
Thanks for the additional bug report; as you say, you should be able to delete all the points.

Bruce Sherwood

unread,
May 18, 2017, 3:49:47 PM5/18/17
to VPython-users
The new VPython 7 fixes these curve bugs.
Reply all
Reply to author
Forward
0 new messages