%matplotlib inline
import xarray as xr
import seaborn as sns
import matplotlib.pyplot as plt

get_ipython().run_line_magic('pylab', 'inline')
#sns.set_style("darkgrid")
pylab.rcParams['figure.figsize'] = (16, 8)
pylab.rcParams.update({'font.size': 10})

df = xr.open_dataset("../experiment_results/experiments_20190301-052407.h5").squeeze()
df

sns.lineplot(x='iteration', y='fidelity', hue='n_layers', data=df.fidelity.sel(n_shots=1000).to_dataframe().reset_index())
plt.legend(df.n_layers.values)
plt.title("Fidelity improvement with optimiser iterations.   (Two determinants with four qubits)")

df.fidelity.max(dim="iteration").mean(dim='run')#.mean(dim='n_layers')

sns.boxenplot(orient='h', x='fidelity', y='n_layers', data=df.fidelity.max(dim='iteration').squeeze().to_dataframe().reset_index())


df.fidelity.max(dim='iteration').squeeze()

