Animated Trajectory from a .csv file

28 views
Skip to first unread message

Ceren Guzelgun

unread,
Jun 12, 2016, 10:28:09 AM6/12/16
to sage-support
Hi everyone. 

I have a csv file saved in a project, a file that has two columns of data. 
I want to animate these points like a trajectory. So far, I can only plot it normally as:

------
import csv
import sys

f = open('test.csv', 'rt')

xArr=[]
yArr=[]
line=f.readline()
while(line !=''): 
    xy=line.split(',')
    xArr.append(float(xy[0]))
    yArr.append(float(xy[1]))
    line=f.readline()

list_plot(zip(xArr,yArr))
------

And as a result ofcourse, I get my plot inanimate.

Is there anyway I can animate it point by point?
Thanks already.

Dominique Laurain

unread,
Jun 12, 2016, 11:02:59 AM6/12/16
to sage-support
Hello,


sines = [plot(c*sin(x), (-2*pi,2*pi), color=Color(c,0,0), ymin=-1,ymax=1) for c in sxrange(0,1,.2)]
a = animate(sines)
a.show()

I believe you are not so far .... add some lines more to your code

Dominique

Ceren Guzelgun

unread,
Jun 12, 2016, 11:49:08 AM6/12/16
to sage-support
Unfortunately, the demo example(s) weren't helpful.
More info, and suggestions would be much aprreciated.

12 Haziran 2016 Pazar 18:02:59 UTC+3 tarihinde Dominique Laurain yazdı:
Reply all
Reply to author
Forward
0 new messages