import matplotlib.pyplot as plt
import matplotlib
import numpy as np
import json

matplotlib.rcParams.update({'errorbar.capsize': 2})

results_naive = np.genfromtxt("qbit_scaling_naive.csv")
results_graph = np.genfromtxt("qbit_scaling_graph.csv")
with open("qbit_scaling_meta.json") as fin:
    meta = json.load(fin)


h0 = plt.errorbar(results_naive[:, 0], results_naive[:, 2], results_naive[:, 3]
                , label=f"Dense Vector Simulator $N_c={int(results_naive[:, 1][0])}$ circuits"
                , marker="o"
                , color="black")
h1 = plt.errorbar(results_graph[:, 0], results_graph[:, 2], results_graph[:, 3]
                , label=f"Graphical Simulator $N_c={int(results_graph[:, 1][0])}$ circuits"
                , marker="^"
                , color="black")

plt.legend(handles=[h0, h1])
plt.xlabel("Number of Qbits $N_q$")
plt.ylabel("Execution time per circuit [s]")
plt.title(f"Execution Time for ${meta['ngates_per_qbit']}\\times N_q$ Gates with random Circuits (rescaled)")

plt.show()
#plt.savefig("scaling_qbits_linear.png", dpi=400)