import numpy as np
import matplotlib.pyplot as plt
plt.style.use("ggplot")
from pprint import pprint
import pickle
import time
import datetime
%matplotlib inline

with open("e2d1_raw.pkl", "rb") as f:
    raw = pickle.load(f)
with open("e2d1_qrem.pkl", "rb") as f:
    qrem = pickle.load(f)
with open("e2d1_zne.pkl", "rb") as f:
    zne = pickle.load(f)
with open("e2d1_zne_pt.pkl", "rb") as f:
    zne_pt = pickle.load(f)

num_steps_list = raw["num_steps_list"]
raw_fid_list = raw["fid"]
raw_stddev_list = raw["stddev"]

num_steps_list = qrem["num_steps_list"]
qrem_fid_list = qrem["fid"]
qrem_stddev_list = qrem["stddev"]

num_steps_list = zne["num_steps_list"]
zne_fid_list = zne["fid"]
zne_stddev_list = zne["stddev"]

num_steps_list = zne_pt["num_steps_list"]
zne_pt_fid_list = zne_pt["fid"]
zne_pt_stddev_list = zne_pt["stddev"]

plt.clf()
plt.figure(dpi=200)
plt.scatter(num_steps_list, raw_fid_list)
plt.scatter(num_steps_list, qrem_fid_list)
plt.scatter(num_steps_list, zne_fid_list)
plt.scatter(num_steps_list, zne_pt_fid_list)

limit = 13
plt.clf()
plt.figure(dpi=200)
plt.scatter(num_steps_list[:limit], raw_fid_list[:limit], marker="o")
plt.scatter(num_steps_list[:limit], qrem_fid_list[:limit], marker="v")
plt.scatter(num_steps_list[:limit], zne_fid_list[:limit], marker="x")
plt.scatter(num_steps_list[:limit], zne_pt_fid_list[:limit], marker="*")
plt.xlabel("number of trotter steps")
plt.ylabel("state fidelity")
plt.legend(("without error mitigations", "with QREM", "with QREM and ZNE", "with QREM, ZNE and Pauli Twirling"))
plt.title("The effect of error mitigations")

zne_pt_fid_list[12]







import qiskit.tools.jupyter
%qiskit_version_table