# coding: utf-8 import numpy as np import matplotlib.pyplot as pl def DWAVE(str,datay,ymax): pl.text(300,ymax, str, ha = 'right', va = 'top') pl.xlabel('Time (sec)',fontsize=12) pl.ylabel('Acceleration (gal)',fontsize=12) pl.xlim(0, 300) pl.ylim(-ymax, ymax) # pl.xticks(np.linspace(0.0, 300.0, 6, endpoint=True)) # pl.yticks(np.linspace(-ymax, ymax, 3, endpoint=True)) pl.xticks(np.arange(0, 360, 60)) pl.yticks(np.arange(-ymax,2*ymax,ymax)) ax = pl.gca() # gca stands for 'get current axis' ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom') ax.spines['bottom'].set_position(('data',-ymax)) ax.yaxis.set_ticks_position('left') ax.spines['left'].set_position(('data',0)) pl.plot(datax,datay, label='acc') datay1 = np.loadtxt("dat_acc_TCGH16_EW2.csv",delimiter=",", skiprows=3) datay2 = np.loadtxt("dat_acc_TCGH16_NS2.csv",delimiter=",", skiprows=3) datay3 = np.loadtxt("dat_acc_TCGH16_UD2.csv",delimiter=",", skiprows=3) ymax1=max(abs(np.amin(datay1)),abs(np.amax(datay1))) ymax2=max(abs(np.amin(datay2)),abs(np.amax(datay2))) ymax3=max(abs(np.amin(datay3)),abs(np.amax(datay3))) datax = np.arange(0.0, float(datay1.size)*0.01, 0.01) fig=pl.figure(num=1,figsize=(8, 8), dpi=100) pl.subplot(3,1,1) str='TCGH16_EW2' ymax=ymax1 datay=datay1 DWAVE(str,datay,ymax) pl.subplot(3,1,2) str='TCGH16_NS2' ymax=ymax2 datay=datay2 DWAVE(str,datay,ymax) pl.subplot(3,1,3) str='TCGH16_UD2' ymax=ymax3 datay=datay3 DWAVE(str,datay,ymax) pl.tight_layout() pl.suptitle('TCGH16') #pl.show() pl.savefig("fig_acc.png", dpi=100)