# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colorbar as clb
import matplotlib.patches as mpatches
import matplotlib.lines as mlines
from matplotlib.mlab import griddata
import scipy.interpolate

p_alpha = 1
fig, ax = plt.subplots(figsize=(12, 9))


comp = []
comp = np.loadtxt('EAPB.dat',delimiter=',')

#comp2 = []
#comp2 = np.loadtxt('EAPB_Model2.dat',delimiter=',')


x = comp[:,2]
y = comp[:,3]
z = comp[:,4]

xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
xi, yi = np.meshgrid(xi, yi)

zi = scipy.interpolate.griddata((x, y), z, (xi, yi), method='linear')

plt.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower',
       extent=[x.min(), x.max(), y.min(), y.max()], aspect='auto') 

cbar = plt.colorbar()
cbar.ax.tick_params(labelsize=20, pad=10)
cbar.ax.set_ylabel(r'$E_{APB}$, $J/m^2$',fontsize=35, labelpad=15)

ax.scatter(comp[:,2],comp[:,3],s=100,facecolors='none', edgecolors='k')

ax.set_xlabel(r'$T_{s}$, Kelvin', fontsize=35, labelpad=15)
ax.set_ylabel(r'$\bar{X}_{Al}^{\gamma^{                            \prime}}$', fontsize=35, labelpad=15)
ax.tick_params(axis='x', labelsize=25, pad = 10)
ax.tick_params(axis='y', labelsize=25, pad = 10)

#ax.set_xscale("log", nonposx='clip')
#ax.set_yscale("log", nonposx='clip')
#ax.set_xlim(0.5, 1E4)
#ax.set_ylim(0, 5)

#colorbar(ct)

ax.grid(True)
fig.tight_layout()


plt.show()

