1import matplotlib.pyplot
as plt
3from matplotlib
import animation
4from mpl_toolkits.mplot3d
import Axes3D
11 with open(file, encoding=
"utf8")
as f:
15 xi, yi, zi = map(float, line.strip().split(
","))
24def update(num, lines, arr):
25 for line, a
in zip(lines, arr):
26 line.set_data(a[:2, num - 1 : num])
27 line.set_3d_properties(a[2, num])
31 plt.style.use(
"dark_background")
33 ax = fig.add_subplot(projection=
"3d")
35 arr = get_data([f
"output/simulate_100_particles/particle_{i}.txt" for i
in range(100)])
41 lines = [ax.plot(*a[:, 1],
"o")[0]
for a
in arr]
43 ax.set_title(
"100 particles inside a Penning trap")
47 "100 randomly generated particles "
48 "evolving over a time of 50 microseconds.",
50 horizontalalignment=
"center",
53 ax.set_xlim3d([-500.0, 500.0])
54 ax.set_xlabel(
"X (micrometers)")
56 ax.set_ylim3d([-500.0, 500.0])
57 ax.set_ylabel(
"Y (micrometers)")
59 ax.set_zlim3d([-500.0, 500.0])
60 ax.set_zlabel(
"Z (micrometers)")
62 ani = animation.FuncAnimation(
63 fig, update, N, fargs=(lines, arr), interval=1, blit=
False
70if __name__ ==
"__main__":