#!/usr/bin/env python
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

# E, Zcom, standard error
LO = np.array(
[[89.2, 2.0835938681818185, 0.043219446562248603],
[102.4, 2.052411924090909, 0.0399449970924927],
[111.8, 2.0294408, 0.02253595762498312],
[120.0, 1.8888191163636363, 0.030146711249031812]]
)

# E, top, hollow, bridge, total
v1 = np.array(
[[89.2, 2.0717716996296294, 0.0356370892973802],
[97.4, 1.9927478392, 0.020941497659717152],
[102.4, 2.006318950956522, 0.014399997294435812],
[111.8, 1.9622278928695651, 0.012724498986270373],
[120.0, 1.916191368395062, 0.01823091269935787]]
)

ni_LO = np.array(
[[101.1, 1.9634796049999999, 0.027461637810604414],
[112.3, 1.8548611964285715, 0.016640689712508032],
[121.2, 1.8999263464999998, 0.018707322018357737]]
#[130.7, 1.8248015499999994, 0.012360467221014049],
#[136.4, 1.7943667811475412, 0.01884349191519778],
#[146.6, 1.7598101856603774, 0.013004591754370557],
#[160.4, 1.7257760226618704, 0.011026268898425742]]
)

ni_v1 = np.array(
[[71.4, 2.116963927272727, 0.03614379116346342],
[89.2, 1.9701508209999998, 0.020911657698130172],
[101.1, 1.9153596457777777, 0.021309995098498784],
[112.3, 1.868057333076923, 0.016279244464800873],
[121.2, 1.843672520595238, 0.01635055282348292],
[130.7, 1.8005758840196078, 0.01542763415272075],
[136.4, 1.786614269268293, 0.014722281981294287],
[146.6, 1.7412462413664596, 0.011918512378853698],
[160.4, 1.6948068764356439, 0.010267756528110164]]
)

pt_LO = np.array(
[[81.7, 2.321769746521739, 0.027460614804187336],
[89.3, 2.2331089260000003, 0.01931168987745782],
[97.4, 2.1896467663333334, 0.01846848454661177],
[102.5, 2.1759102625581392, 0.015528425487625282],
[111.9, 2.156272917446808, 0.017394275530128393],
[120.1, 2.1354741255714282, 0.014768347756813419]]
)

pt_v1 = np.array(
[[60.7, 2.3410037032, 0.030939455189952968],
[71.4, 2.297707025416667, 0.03445602145119364],
[81.9, 2.2711882378125, 0.026183140039089954],
[92.2, 2.2256250916666667, 0.016594509940060932],
[104.6, 2.179295217246376, 0.014077280914775383]]
)

mpl.rc("text", usetex=True)
fig = plt.figure(figsize=(3.69,3))
#fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(3.69,3.))

#plt.subplot(2,1,1)

plt.errorbar( ni_LO[:,0], ni_LO[:,1], yerr=ni_LO[:,2], marker='s', label='Ni(111)', color='b' )
plt.errorbar( ni_v1[:,0], ni_v1[:,1], yerr=ni_v1[:,2], marker='s', color='b', linestyle='--', fillstyle='none')
plt.errorbar( LO[:,0], LO[:,1], yerr=LO[:,2], marker='o', label='Pd(111)', color='k' )
plt.errorbar( v1[:,0], v1[:,1], yerr=v1[:,2], marker='o', color='k', linestyle='--', fillstyle='none')
plt.errorbar( pt_LO[:,0], pt_LO[:,1], yerr=pt_LO[:,2], marker='^', label='Pt(111)', color='r' )
plt.errorbar( pt_v1[:,0], pt_v1[:,1], yerr=pt_v1[:,2], marker='^', color='r', linestyle='--', fillstyle='none')

plt.plot([0., 400.], [2.18,2.18], linestyle=':', color='b', label='')
plt.plot([0., 400.], [2.23,2.23], linestyle=':', color='k', label='')
plt.plot([0., 400.], [2.28,2.28], linestyle=':', color='r', label='')

plt.legend(loc='best', numpoints=1, frameon=True)
#plt.legend(loc='upper left', numpoints=1, handletextpad=0.5, borderaxespad=0.2, frameon=False)
plt.xlim(50.,170.)
plt.ylim(1.6,2.75)
plt.tick_params(length=6, width=1)
plt.ylabel(r'Z$_{C}$ (\r{A})')
plt.xlabel('Incidence energy (kJ/mol)')

plt.tight_layout()
plt.subplots_adjust(wspace=0, hspace=0)
plt.savefig('Zc_ts_comparison.pdf')
#plt.show()
