-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplotter.py
More file actions
34 lines (25 loc) · 915 Bytes
/
Copy pathplotter.py
File metadata and controls
34 lines (25 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import matplotlib
matplotlib.use('TKAgg')
from parameters import *
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
plt.rcParams['animation.ffmpeg_path'] = '/usr/local/bin/ffmpeg'
fig = plt.figure()
fig.set_size_inches(12, 10)
ax = plt.axes(xlim=(0, SIZE), ylim=(-6, 6))
scat = ax.scatter([], [], c = '0.2', lw = 0, s = 10)
def init():
scat.set_offsets([])
return scat,
def animate(i):
filename = 'dats/' + NAME + '/step_' + str(i) + ".dat"
x, y = np.loadtxt(filename, unpack = True)
data = np.hstack((x[:len(x),np.newaxis],y[:len(x),np.newaxis]))
scat.set_offsets(data)
return scat,
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=STEPS, interval=1, blit=False)
writer = animation.writers['ffmpeg'](fps=60)
anim.save('results/' + NAME + '.mp4', writer = writer, dpi = 150)
# plt.show()