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

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.lines as mlines
import matplotlib.gridspec as gridspec
from matplotlib.ticker import LogLocator

YSH = []
YSH = np.loadtxt('H/YStress.dat',delimiter=',')
YSM1 = []
YSM1 = np.loadtxt('M1/YStress.dat',delimiter=',')
YSM2 = []
YSM2 = np.loadtxt('M2/YStress.dat',delimiter=',')
YSL = []
YSL = np.loadtxt('L/YStress.dat',delimiter=',')

YSH = np.delete(YSH,0,0)
YSM1 = np.delete(YSM1,0,0)
YSM2 = np.delete(YSM2,0,0)
YSL = np.delete(YSL,0,0)

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

widthline = 3
flabsize = 45
fticksize = 30


ax.plot(YSH[:,0],YSH[:,7], c='r',linewidth=4,label='Opt-H',zorder=5)
ax.plot(YSM1[:,0],YSM1[:,7], c='m',linewidth=4,label='Opt-M1',zorder=4)
ax.plot(YSM2[:,0],YSM2[:,7], c='y',linewidth=4,label='Opt-M2',zorder=3)
ax.plot(YSL[:,0],YSL[:,7], c='b',linewidth=4,label='Opt-L',zorder=1)

ax.set_xlabel(u'$t$, min', fontsize=flabsize, labelpad=15)
ax.set_ylabel(u'$\sigma_{ys}$, MPa', fontsize=flabsize, labelpad=15)

ax.tick_params(axis='x', labelsize=fticksize, pad = 10)
ax.tick_params(axis='y', labelsize=fticksize, pad = 10, colors='black')


#ax.xaxis.grid(True)

ax.set_xscale("log", nonposx='clip')
#ax2_2.set_yscale("log", nonposx='clip')
#ax.set_xlim(0, 80)
#ax.set_ylim(0, 800)

#plt.locator_params(axis = 'x', nbins = 4)
plt.locator_params(axis = 'y', nbins = 5)
handles, labels = ax.get_legend_handles_labels()
plt.legend(handles, labels, loc='upper left', fontsize=25)

ax.xaxis.set_major_locator(LogLocator(base = 1000.0))
ax.set_xlim(1E-4, 1E6)
ax.set_ylim(0, 1200)
#ax.grid(True)
#ax2.grid(True)

fig.tight_layout()


plt.show()

