-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
30 lines (21 loc) · 661 Bytes
/
plot.py
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
import numpy as np
import matplotlib.pyplot as plt
import imageio
fid = [str(i) for i in range(1,38)] # File 'IDs' or iteration numbers
fname = ["particles."+ str(i)+".dat" for i in fid] # Get full filenames
imname = [str(i)+".png" for i in fname]
for file in fname:
pos = np.loadtxt(file)
x = pos[:,0]
y = pos[:,1]
fig = plt.figure(figsize=(10, 10))
plt.scatter(x,y,color='black')
plt.xlim((-0.5,0.5))
plt.ylim((-0.5,0.5))
plt.grid(True)
plt.savefig(file+'.png')
plt.close()
writer = imageio.get_writer('movie.mp4')
for im in imname:
writer.append_data(imageio.imread(im))
writer.close()