Latexify the plots

This commit is contained in:
Janita Willumsen
2023-10-20 15:58:49 +02:00
parent 10a565eb24
commit f52892c1a6
6 changed files with 105 additions and 16 deletions

View File

@@ -1,5 +1,19 @@
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set_theme()
params = {
"font.family": "Serif",
"font.serif": "Roman",
"text.usetex": True,
"axes.titlesize": "large",
"axes.labelsize": "large",
"xtick.labelsize": "large",
"ytick.labelsize": "large",
"legend.fontsize": "medium"
}
plt.rcParams.update(params)
def main():
directories = {
@@ -22,7 +36,7 @@ def main():
"Relative error for the RK4 method",
"Relative error for the forward Euler method"
]
fig1, axs1 = plt.subplots(2,1)
fig1, axs1 = plt.subplots(2,1, sharex=True)
for i, (dir, title) in enumerate(zip(directories, titles)):
max_err = []
for label, file in zip(labels, files):
@@ -33,17 +47,17 @@ def main():
max_err.append(max(r))
axs1[i].plot(t, r, label=label)
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"relative_error $(\mu m)$")
axs1[i].set(ylabel = r"relative_error $(\mu m)$") # xlabel=r"t $(\mu s)$",
axs1[1].set_xlabel(r"t $(\mu s)$")
axs1[i].legend()
axs1[i].set_title(title)
# axs1[i].set_title(title)
conv_rate = 1/3 * sum([np.log10(max_err[i+1]/max_err[i])/np.log10(.5) for i in range(3)])
print(conv_rate)
plt.show()
# fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
plt.show()
if __name__ == "__main__":