From b8f32f1fd9e7b1b6c21f3b354d80d84500bec0a0 Mon Sep 17 00:00:00 2001 From: Janita Willumsen Date: Sun, 22 Oct 2023 14:22:03 +0200 Subject: [PATCH] Update plot with seaborn theme --- src/scripts/plot_2_particles.py | 2 +- src/scripts/plot_particles_left.py | 31 ++++++++++++++++++++--------- src/scripts/plot_single_particle.py | 20 ++++++++++++------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/scripts/plot_2_particles.py b/src/scripts/plot_2_particles.py index 7acfa50..be7838b 100644 --- a/src/scripts/plot_2_particles.py +++ b/src/scripts/plot_2_particles.py @@ -45,7 +45,7 @@ def main(): plt.ylabel(r"y $(\mu m)$") # plt.title(r"2 particles with and without interactions.") plt.legend(loc="upper right") - plt.savefig("../latex/images/plot_2_particles_xy.pdf") + plt.savefig("../latex/images/plot_2_particles_xy.pdf", bbox_inches="tight") plt.show() diff --git a/src/scripts/plot_particles_left.py b/src/scripts/plot_particles_left.py index 42e65b9..9884cd2 100644 --- a/src/scripts/plot_particles_left.py +++ b/src/scripts/plot_particles_left.py @@ -15,6 +15,14 @@ params = { plt.rcParams.update(params) def main(): + colors = [ + "lightskyblue", + "deepskyblue", + "salmon", + "tomato", + "mediumaquamarine", + "mediumseagreen" + ] with open("output/time_dependent_potential/res.txt") as f: lines = f.readlines() x = [] @@ -28,17 +36,22 @@ def main(): y2.append(float(l[2])) y3.append(float(l[3])) - plt.plot(x,y1,label=f"amplitude: 0.1") - plt.plot(x,y2,label=f"amplitude: 0.4") - plt.plot(x,y3,label=f"amplitude: 0.7") + fig, ax = plt.subplots() + ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0]) + ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[2]) + ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[4]) + + ax.set_xlabel(r"Frequency $\omega_V$ (MHz)") + ax.set_xlim((0, 2.8)) + ax.set_ylabel(r"Fraction of particles left") + ax.set_ylim((-0.1, 1.1)) + # plt.title(r"The fraction of particles left in the Penning trap " + # "after 500 microseconds for different amplitudes and frequencies") + + ax.legend(loc="upper right") - plt.xlabel(r"$\omega_V$ (MHz)") - plt.ylabel(r"Fraction of particles left") - plt.title(r"The fraction of particles left in the Penning trap " - "after 500 microseconds for different amplitudes and frequencies") - plt.legend() # plt.show() - plt.savefig("../latex/images/particles_left.pdf") + fig.savefig("../latex/images/particles_left.pdf", bbox_inches="tight") if __name__ == "__main__": main() diff --git a/src/scripts/plot_single_particle.py b/src/scripts/plot_single_particle.py index 77ea776..6ee2d16 100644 --- a/src/scripts/plot_single_particle.py +++ b/src/scripts/plot_single_particle.py @@ -28,6 +28,8 @@ def main(): "deepskyblue", "salmon", "tomato", + "mediumaquamarine", + "mediumseagreen" ] filename = "output/simulate_single_particle/particle_0_r.txt" r = t = [] @@ -35,14 +37,18 @@ def main(): lines = f.readlines() t = np.linspace(0, 50, len(lines)) r = np.array([list(map(float, line.strip().split(","))) for line in lines]) - plt.plot(t, r[:, 2], label="approximation", color=colors[1]) - plt.plot(t, z(t), label="analytical", color=colors[2], linestyle="dotted") - plt.xlabel(r"time $(\mu s)$") - plt.ylabel(r"z $(\mu m)$") + + fig, ax = plt.subplots() + ax.plot(t, r[:, 2], label="approximation", color=colors[3]) + ax.plot(t, z(t), label="analytical", color=colors[5], linestyle="dotted") + ax.set_xlabel(r"Time $(\mu s)$") + ax.set_xlim((-5, 55)) + ax.set_ylabel(r"z $(\mu m)$") + ax.set_ylim((-25, 25)) # plt.title(r"Movement of a single particle in the x direction") - plt.legend(loc="lower right") - plt.savefig("../latex/images/single_particle.pdf") - plt.show() + ax.legend(loc="upper right") + fig.savefig("../latex/images/single_particle.pdf", bbox_inches="tight") + # plt.show() if __name__ == "__main__":