Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7fb0bd66 authored by Fabien Grzeskowiak's avatar Fabien Grzeskowiak
Browse files

#19 basic output files

parent ac32e8cf
No related merge requests found
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from sys import argv
script, filename = argv
traj = open(filename,'r').read()
lines = traj.split('\n')
t = []
x = []
y = []
for line in lines :
if len(line) > 1 :
ti, xi, yi = line.split(" ")
t.append(ti)
x.append(xi)
y.append(yi.rstrip())
plt.plot(x,y,'ro')
plt.show()
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from sys import argv
script, filename = argv
traj = open(filename,'r').read()
lines = traj.split('\n')
t = []
x = []
y = []
for line in lines :
if len(line) > 1 :
ti, xi, yi = line.split(" ")
t.append(float(ti))
x.append(float(xi))
y.append(float(yi.rstrip()))
fig = plt.figure()
plt.title('Trajectory of an agent, file :' + filename)
plt.xlabel('X (m)')
plt.ylabel('Y (m)')
ax = fig.add_subplot(1,1,1)
ax.grid(True, linestyle = '-', color = '0.75')
ax.set_xlim([-5, 20])
ax.set_ylim([-5, 20])
traj = open('f3.txt','r').read()
lines = traj.split('\n')
ax.set_xlim([min(x), max(x)])
ax.set_ylim([min(y), max(y)])
def _update_plot(i):
#if i > len(lines) :
# return
t, x, y = lines[i].split(" ")
#ax.clear()
ax.plot(x,y,'ro')
ax.plot(x[100*i],y[100*i],'ro')
anim = animation.FuncAnimation(fig, _update_plot, interval = 10)
anim = animation.FuncAnimation(fig, _update_plot, interval = 100*t[0])
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment