Formatting
This commit is contained in:
parent
ef1d54b776
commit
83468938bb
@ -10,29 +10,23 @@ params = {
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
"legend.fontsize": "medium",
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
|
||||
def plot_from_file():
|
||||
files = [
|
||||
# "output/burn_in_time/unordered_1_0_1421110368.txt",
|
||||
# "output/burn_in_time/ordered_1_0_611577739.txt",
|
||||
"output/burn_in_time/unordered_2_4_1212892317.txt",
|
||||
"output/burn_in_time/ordered_2_4_2408603856.txt",
|
||||
"data/hp/burn_in_time/unordered_2_4_1212892317.txt",
|
||||
"data/hp/burn_in_time/ordered_2_4_2408603856.txt",
|
||||
]
|
||||
labels = [
|
||||
"Unordered",
|
||||
"Ordered",
|
||||
# "2.4, unordered",
|
||||
# "2.4, ordered"
|
||||
]
|
||||
colors = [
|
||||
"darkred",
|
||||
"seagreen",
|
||||
# "steelblue",
|
||||
# "darkred",
|
||||
# "darkgoldenrod",
|
||||
]
|
||||
|
||||
fig1, ax1 = plt.subplots()
|
||||
@ -57,14 +51,19 @@ def plot_from_file():
|
||||
ax1.set_xlabel("t")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$")
|
||||
ax1.legend(title="Initial state", loc="upper right")
|
||||
fig1.savefig("../latex/images/burn_in_time_energy_2_4.pdf", bbox_inches="tight")
|
||||
|
||||
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", loc="upper right")
|
||||
fig2.savefig("../latex/images/burn_in_time_magnetization_2_4.pdf", bbox_inches="tight")
|
||||
fig2.savefig(
|
||||
"./latex/images/burn_in_time_magnetization_2_4.pdf", bbox_inches="tight"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
plot_from_file()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import os
|
||||
from os import makedirs
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
@ -15,14 +15,14 @@ params = {
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
"legend.fontsize": "medium",
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
|
||||
def plot(infile, outfile):
|
||||
if not (outdir := Path(outfile).parent).exists():
|
||||
os.makedirs(outdir)
|
||||
makedirs(outdir)
|
||||
|
||||
figure1, ax1 = plt.subplots()
|
||||
eps = []
|
||||
@ -32,21 +32,32 @@ def plot(infile, outfile):
|
||||
vals = line.strip().split(",")
|
||||
eps.append(float(vals[0]))
|
||||
|
||||
ax1.hist(eps, np.arange(min(eps), max(eps) + 0.02, 0.02), color="steelblue", density=True, ec="white", lw=0.2)
|
||||
ax1.hist(
|
||||
eps,
|
||||
np.arange(min(eps), max(eps) + 0.02, 0.02),
|
||||
color="steelblue",
|
||||
density=True,
|
||||
ec="white",
|
||||
lw=0.2,
|
||||
)
|
||||
ax1.set_xlabel(r"$\epsilon$")
|
||||
ax1.set_ylabel("Density")
|
||||
|
||||
mu, sigma = np.mean(eps), np.std(eps)
|
||||
x = np.arange(min(eps), max(eps) + 0.02, 0.02)
|
||||
|
||||
stats = (f"$\\langle \\epsilon \\rangle$ = {np.mean(eps):.4f}\n"
|
||||
f"Var$(\\epsilon)$ = {np.var(eps):.4f}")
|
||||
stats = (
|
||||
f"$\\langle \\epsilon \\rangle$ = {np.mean(eps):.4f}\n"
|
||||
f"Var$(\\epsilon)$ = {np.var(eps):.4f}"
|
||||
)
|
||||
bbox = dict(boxstyle="round", pad=0.3, fc="white", ec="white", alpha=0.5)
|
||||
ax1.text(0.95, 0.9, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center")
|
||||
ax1.text(
|
||||
0.95, 0.9, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center"
|
||||
)
|
||||
ax1.plot(x, norm.pdf(x, mu, sigma), color="mediumseagreen")
|
||||
figure1.savefig(outfile, bbox_inches="tight")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot("output/pd_estimate/estimate_1_0.txt", "../latex/images/pd_estimate_1_0.pdf")
|
||||
plot("output/pd_estimate/estimate_2_4.txt", "../latex/images/pd_estimate_2_4.pdf")
|
||||
plot("./data/hp/pd_estimate/estimate_1_0.txt", "./latex/images/pd_estimate_1_0.pdf")
|
||||
plot("./data/hp/pd_estimate/estimate_2_4.txt", "./latex/images/pd_estimate_2_4.pdf")
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from os import makedirs
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
@ -6,6 +7,9 @@ from scipy.stats import linregress
|
||||
|
||||
|
||||
def plot_phase_transition_alt(indir, outdir):
|
||||
if not (path := Path(outdir)).exists():
|
||||
makedirs(path)
|
||||
|
||||
files = [
|
||||
"size_20.txt",
|
||||
"size_40.txt",
|
||||
@ -84,6 +88,9 @@ def plot_phase_transition_alt(indir, outdir):
|
||||
|
||||
|
||||
def plot_phase_transition(indir, outdir):
|
||||
if not (path := Path(outdir)).exists():
|
||||
makedirs(path)
|
||||
|
||||
files = [
|
||||
"size_20.txt",
|
||||
"size_40.txt",
|
||||
@ -168,24 +175,24 @@ def plot_phase_transition(indir, outdir):
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot_phase_transition_alt(
|
||||
"fox_output/phase_transition/wide/10M/",
|
||||
"data/fox/phase_transition/wide/10M/",
|
||||
"latex/images/phase_transition/fox/wide/10M/",
|
||||
)
|
||||
plot_phase_transition(
|
||||
"fox_output/phase_transition/wide/1M/",
|
||||
"data/fox/phase_transition/wide/1M/",
|
||||
"latex/images/phase_transition/fox/wide/1M/",
|
||||
)
|
||||
plot_phase_transition(
|
||||
"fox_output/phase_transition/narrow/10M/",
|
||||
"data/fox/phase_transition/narrow/10M/",
|
||||
"latex/images/phase_transition/fox/narrow/10M/",
|
||||
)
|
||||
plot_phase_transition(
|
||||
"output/phase_transition/", "latex/images/phase_transition/hp/"
|
||||
"data/hp/phase_transition/", "latex/images/phase_transition/hp/"
|
||||
)
|
||||
plot_phase_transition(
|
||||
"output/phase_transition/", "latex/images/phase_transition/hp/"
|
||||
"data/hp/phase_transition/", "latex/images/phase_transition/hp/"
|
||||
)
|
||||
plot_phase_transition(
|
||||
"output/phase_transition/",
|
||||
"data/hp/phase_transition/",
|
||||
"latex/images/phase_transition/hp/",
|
||||
)
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
from os import makedirs
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from scipy.stats import linregress
|
||||
|
||||
|
||||
def plot_phase_transition(indir, outdir):
|
||||
def plot(indir, outdir):
|
||||
if not (path := Path(outdir)).exists():
|
||||
makedirs(path)
|
||||
|
||||
files = [
|
||||
"no_burn_in.txt",
|
||||
"burn_in.txt",
|
||||
@ -20,7 +22,6 @@ def plot_phase_transition(indir, outdir):
|
||||
figure3, ax3 = plt.subplots()
|
||||
figure4, ax4 = plt.subplots()
|
||||
|
||||
|
||||
for file, label in zip(files, labels):
|
||||
t = []
|
||||
e = []
|
||||
@ -38,13 +39,11 @@ def plot_phase_transition(indir, outdir):
|
||||
CV.append(float(l[3]))
|
||||
X.append(float(l[4]))
|
||||
|
||||
|
||||
ax1.plot(t, e, label=label)
|
||||
ax2.plot(t, m, label=label)
|
||||
ax3.plot(t, CV, label=label)
|
||||
ax4.plot(t, X, label=label)
|
||||
|
||||
|
||||
figure1.legend()
|
||||
figure2.legend()
|
||||
figure3.legend()
|
||||
@ -62,7 +61,7 @@ def plot_phase_transition(indir, outdir):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot_phase_transition(
|
||||
"output/test_burn_in_time/",
|
||||
"../latex/images/test_burn_in",
|
||||
plot(
|
||||
"./data/hp/test_burn_in_time/",
|
||||
"./latex/images/test_burn_in",
|
||||
)
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
from os import makedirs
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from scipy.stats import linregress
|
||||
|
||||
|
||||
def plot_timing(indir, outdir):
|
||||
if not (path := Path(outdir)).exists():
|
||||
makedirs(path)
|
||||
|
||||
files = [
|
||||
"lattice_sizes.txt",
|
||||
"sample_sizes.txt",
|
||||
@ -14,14 +16,8 @@ def plot_timing(indir, outdir):
|
||||
"Lattice sizes",
|
||||
"Sample sizes",
|
||||
]
|
||||
xlabels = [
|
||||
"Lattice size",
|
||||
"Sampling size"
|
||||
]
|
||||
outfiles = [
|
||||
"lattice_size.pdf",
|
||||
"sample_sizes.pdf"
|
||||
]
|
||||
xlabels = ["Lattice size", "Sampling size"]
|
||||
outfiles = ["lattice_size.pdf", "sample_sizes.pdf"]
|
||||
|
||||
for file, label, xlabel, outfile in zip(files, labels, xlabels, outfiles):
|
||||
figure1, ax1 = plt.subplots()
|
||||
@ -35,7 +31,6 @@ def plot_timing(indir, outdir):
|
||||
x.append(float(l[0]))
|
||||
t.append(float(l[1]))
|
||||
|
||||
|
||||
ax1.plot(x, t, label=label)
|
||||
ax1.set_xlabel(xlabel)
|
||||
ax1.set_ylabel("time (seconds)")
|
||||
@ -49,6 +44,6 @@ def plot_timing(indir, outdir):
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot_timing(
|
||||
"output/timing/",
|
||||
"../latex/images/timing",
|
||||
"data/hp/timing/",
|
||||
"./latex/images/timing",
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user