Add separate plot for each temperature

This commit is contained in:
Janita Willumsen 2023-11-25 13:48:13 +01:00
parent 7afb51357e
commit cd1820b1a4

View File

@ -1,22 +1,43 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
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 plot_from_file(): def plot_from_file():
files = [ files = [
"output/burn_in_time/unordered_1_0.txt", # "output/burn_in_time/unordered_1_0_1421110368.txt",
"output/burn_in_time/ordered_1_0.txt", # "output/burn_in_time/ordered_1_0_611577739.txt",
"output/burn_in_time/unordered_2_4.txt", "output/burn_in_time/unordered_2_4_1212892317.txt",
"output/burn_in_time/ordered_2_4.txt", "output/burn_in_time/ordered_2_4_2408603856.txt",
] ]
labels = [ labels = [
"1.0, unordered", "Unordered",
"1.0, ordered", "Ordered",
"2.4, unordered", # "2.4, unordered",
"2.4, ordered" # "2.4, ordered"
]
colors = [
"seagreen",
"darkred",
# "darkgoldenrod",
# "steelblue"
] ]
figure1, ax1 = plt.subplots()
figure2, ax2 = plt.subplots()
for infile, label in zip(files, labels): fig1, ax1 = plt.subplots()
fig2, ax2 = plt.subplots()
for infile, label, color in zip(files, labels, colors):
with open(infile) as f: with open(infile) as f:
lines = f.readlines() lines = f.readlines()
@ -29,13 +50,17 @@ def plot_from_file():
energy.append(float(items[1])) energy.append(float(items[1]))
magnetization.append(float(items[5])) magnetization.append(float(items[5]))
ax1.plot(t, energy, label=fr"$\langle \epsilon \rangle$ {label}") ax1.plot(t, energy, label=f"{label}", color=color)
ax2.plot(t, magnetization, label=fr"$\langle | m | \rangle$ {label}") ax2.plot(t, magnetization, label=f"{label}", color=color)
figure1.legend() ax1.set_xlabel("t")
figure1.savefig("../latex/images/burn_in_time_energy.pdf") ax1.set_ylabel(r"$\langle \epsilon \rangle$")
figure2.legend() ax1.legend(title="Initial state")
figure2.savefig("../latex/images/burn_in_time_magnetization.pdf") fig1.savefig("../latex/images/burn_in_time_energy_2_4.pdf", bbox_inches="tight")
ax2.set_ylabel(r"$\langle |m| \rangle$")
ax2.set_xlabel("t")
ax2.legend(title="Initial state")
fig2.savefig("../latex/images/burn_in_time_magnetization_2_4.pdf", bbox_inches="tight")
def main(): def main():
plot_from_file() plot_from_file()