42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
def main():
|
|
files = [
|
|
"output/simulate_2_particles/no_interaction/particle_0_r.txt",
|
|
"output/simulate_2_particles/no_interaction/particle_1_r.txt",
|
|
"output/simulate_2_particles/with_interaction/particle_0_r.txt",
|
|
"output/simulate_2_particles/with_interaction/particle_1_r.txt"
|
|
]
|
|
labels = [
|
|
"particle 1 no interaction",
|
|
"particle 2 no interaction",
|
|
"particle 1 with interaction",
|
|
"particle 2 with interaction",
|
|
]
|
|
colors = [
|
|
"lightskyblue",
|
|
"salmon",
|
|
"deepskyblue",
|
|
"darkred"
|
|
]
|
|
ax = plt.figure().add_subplot(projection="3d")
|
|
for label, color, file in zip(labels, colors, files):
|
|
with open(file) as f:
|
|
lines = f.readlines()
|
|
t = np.linspace(0, 50, len(lines))
|
|
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
|
ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
|
|
|
|
ax.set_xlabel(r"x $(\mu m)$")
|
|
ax.set_ylabel(r"y $(\mu m)$")
|
|
ax.set_zlabel(r"z $(\mu m)$")
|
|
ax.view_init(10,45)
|
|
plt.title(r"2 particles with and without interactions.")
|
|
plt.legend()
|
|
plt.savefig("../latex/images/3d_plot.pdf")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|