# -*- 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.ticker import LogLocator

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

comp = []
comp = np.loadtxt('YStress.dat',delimiter=',')
#comp2 = []
#comp2 = np.loadtxt('fullD/YStress.dat',delimiter=',')
#ref = []
#ref = np.loadtxt('samples/2008_Effects_sudbrack_r.dat')

#ax.errorbar(ref[:,0], ref[:,1], yerr=ref[:,2], s=150, marker='o', c='r',zorder=3)
#ax.errorbar(ref[:,0], ref[:,1], yerr=ref[:,2], fmt='o', c='r',markersize=15, lw=3)
ax.plot(comp[:,0],comp[:,2], lw=3)
ax2.plot(comp[:,0],comp[:,1],color='r', lw=3)
#ax.plot(comp2[:,0],comp2[:,2],lw=3,c='k')
#ax.bar(comp[:,0],comp[:,2],5)

ax.set_xlabel(u'$t$, min', fontsize=45, labelpad=20)
ax.set_ylabel(r'$\bar{R}^{\gamma^{\prime}}$, nm', fontsize=45, labelpad=15,color='b')
ax2.set_ylabel(r'$V_{f}^{\gamma^{\prime}}$, %', fontsize=45, labelpad=15,color='r')
ax.tick_params(axis='x', labelsize=30, pad = 15)
ax.tick_params(axis='y', labelsize=30, pad = 10,colors='b')
ax2.tick_params(axis='y', labelsize=30, pad = 10,colors='r')

ax.set_xscale("log", nonposx='clip')
ax2.set_xscale("log", nonposx='clip')
#ax.set_yscale("log", nonposx='clip')
ax.set_xlim(1E-4, 1000)
ax.set_ylim(0, 200)
#ax.grid(True)

#plt.locator_params(axis = 'x', nbins = 4)
ax.xaxis.set_major_locator(LogLocator(base = 1000.0))
#ax.set_xlim(0, 500)
ax.locator_params(axis = 'y', nbins = 4)
ax2.locator_params(axis = 'y', nbins = 4)
#ax.text(1.2E-4, 110, 'YS2', fontsize=30)  #, bbox={'facecolor':'none', 'pad':15})

fig.tight_layout()


plt.show()

