# coding: utf-8 # aspect ratio : http://d.hatena.ne.jp/bettamodoki/20120605/1338863706 # custom dashes: http://stackoverflow.com/questions/14710221/python-matplotlib-dash-dot-dot-how-to # font: http://matplotlib.org/examples/api/font_family_rc.html from matplotlib import rcParams rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['Arial'] import numpy as np import matplotlib.pyplot as pl def DRAW(data1,data2,data3,data4,data5,fnameF,bb,hh,TT): gt='b'+str(int(bb))+' x h'+str(int(hh))+': T'+str(int(TT)) xmin=0 xmax=float(int(max(data1[:,0]))+1) ymin=float(int(min(data1[:,1]))//5*5) ymax=float(int(max(data1[:,1]))//5*5+5) dx=np.arange(xmin,xmax+0.5,0.5) dy=np.arange(ymin,ymax+5,5) fig=pl.figure() ax = pl.gca() pl.subplot(1,1,1) pl.xlabel('$M/bh^2$ (MPa)',fontsize=12) pl.ylabel('$N/bh$ (MPa)',fontsize=12) pl.xlim(0,xmax) pl.xticks(dx) pl.ylim(ymin,ymax) pl.yticks(dy) aspect = 0.7*(ax.get_xlim()[1] - ax.get_xlim()[0]) / (ax.get_ylim()[1] - ax.get_ylim()[0]) ax.set_aspect(aspect) line1=pl.plot(data1[:,0],data1[:,1],color='black',linewidth=1.5,label='ctc100 (double)') line2=pl.plot(data2[:,0],data2[:,1],color='black',linewidth=1.5,label='ctc125 (double)') line3=pl.plot(data3[:,0],data3[:,1],color='black',linewidth=1.5,label='ctc150 (double)') line4=pl.plot(data4[:,0],data4[:,1],color='black',linewidth=1.5,label='ctc200 (double)') line5=pl.plot(data5[:,0],data5[:,1],color='black',linewidth=1.5,label='ctc250 (double)') line2[0].set_dashes([6,2,6,2]) line3[0].set_dashes([8,4,2,4]) line4[0].set_dashes([8,4,2,4,2,4]) line5[0].set_dashes([2,2,2,2]) pl.title('Ultimate Strength of Slab ('+gt+')') pl.grid(True,which='both',ls='-', color='0.65') pl.legend(shadow=True,prop={'size':12},loc='upper right',handlelength=3) pl.savefig(fnameF, dpi=100) pl.show() # Main routine bb=1000 hh=1000 for i in [32,25,20]: TT=float(i) fnameF='fig_T'+str(int(TT))+'h'+str(int(hh))+'.eps' data1 = np.loadtxt('out_'+str(int(TT))+'ctc100h'+str(int(hh))+'.txt',usecols=(2,1),skiprows=1) data2 = np.loadtxt('out_'+str(int(TT))+'ctc125h'+str(int(hh))+'.txt',usecols=(2,1),skiprows=1) data3 = np.loadtxt('out_'+str(int(TT))+'ctc150h'+str(int(hh))+'.txt',usecols=(2,1),skiprows=1) data4 = np.loadtxt('out_'+str(int(TT))+'ctc200h'+str(int(hh))+'.txt',usecols=(2,1),skiprows=1) data5 = np.loadtxt('out_'+str(int(TT))+'ctc250h'+str(int(hh))+'.txt',usecols=(2,1),skiprows=1) DRAW(data1,data2,data3,data4,data5,fnameF,bb,hh,TT)