import numpy as np
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():
    files = [
        "data/probability_deviation_no_slits.txt",
        "data/probability_deviation_slits.txt",
    ]
    labels = [
        "none",
        "double-slit"
    ]
    colors = sns.color_palette("mako", n_colors=2)

    fig, ax = plt.subplots() 

    for file, label, color in zip(files, labels, colors):
        with open(file) as f:
            lines = f.readlines()
            x = []
            arr = []
            for line in lines:
                tmp = line.strip().split("\t")
                x.append(float(tmp[0]))
                arr.append(float(tmp[1]))

            ax.plot(x, arr, label=label, color=color)
        
        ax.legend(title="Barrier")
        ax.set_xlabel("Time (t)")
        ax.set_ylabel("Deviation")
    fig.savefig("latex/images/probability_deviation.pdf", bbox_inches="tight")


if __name__ == "__main__":
    plot()