28 lines
735 B
Python
28 lines
735 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
|
|
def plot(infile, outfile):
|
|
if not (outdir := Path(outfile).parent).exists():
|
|
os.makedirs(outdir)
|
|
|
|
figure1, ax1 = plt.subplots()
|
|
arr = []
|
|
with open(infile) as f:
|
|
lines = f.readlines()
|
|
for line in lines:
|
|
vals = line.strip().split(",")
|
|
arr.append(float(vals[0]))
|
|
|
|
ax1.hist(arr, np.arange(min(arr), max(arr) + 0.02, 0.02), density=True, ec="black")
|
|
|
|
figure1.savefig(outfile)
|
|
|
|
|
|
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")
|