from collections import deque
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import json

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

results_graph0 = np.genfromtxt("circuit_scaling_graph0_measurements.csv")
results_graph1 = np.genfromtxt("circuit_scaling_graph1_measurements.csv")
with open("circuit_scaling_measurements_meta.json") as fin:
    meta = json.load(fin)

h0 = plt.errorbar(results_graph0[:, 0], results_graph0[:, 2], results_graph0[:, 3]
                , label=f"Graphical Simulator $N_q={meta['nqbits0']}$ Qbits"
                , marker="^"
                , color="black")
h1 = plt.errorbar(results_graph1[:, 0], results_graph1[:, 2], results_graph1[:, 3]
                , label=f"Graphical Simulator $N_q={meta['nqbits1']}$ Qbits"
                , marker="o"
                , color="black")

plt.legend(handles=[h0, h1])
plt.xlabel("Number of Gates in Circuit")
plt.ylabel("Execution Time per Circuit [s]")
plt.title(f"Execution Time for Random Circuits with Random Measurements")

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