import numpy as np #from math import * import sys import matplotlib.pyplot as plt # Main routine param=sys.argv fnameR=param[1] fnameF=param[2] strt=param[3] pmf=float(param[4]) ttf=float(param[5]) # Input data x=[] y=[] fin=open(fnameR,'r') text=fin.readline() text=text.strip() text=text.split() gi=float(text[0]) while 1: text=fin.readline() if not text: break text=text.strip() text=text.split() x=x+[float(text[0])] y=y+[float(text[1])] fin.close() nn=len(x) z1=[pmf for i in range(0,nn)] z2=[ttf for i in range(0,nn)] xx=np.array(x) yy=np.array(y) el1=np.array(z1) el2=np.array(z2) xmin=-60.0 xmax=100.0 ymin=70.0 ymax=100 fig = plt.figure() ax=fig.add_subplot(111) ax.plot(xx,yy,color='black',lw=1.0,label='ground surface') ax.fill_between(xx,yy,el1,where=yy<=el1,facecolor='cyan',alpha=0.3,interpolate=True) ax.fill_between(xx,yy,el2,where=yy<=el2,facecolor='cyan',alpha=0.3,interpolate=True) ax.text(0,pmf,'PMF',fontsize=10,color='black',ha='left',va='bottom') ax.text(0,ttf,'1000years flood',fontsize=10,color='black',ha='left',va='top') ax.set_title(strt) ax.set_xlabel('Distance (m)') ax.set_ylabel('Elevation (EL.m)') ax.set_xlim(xmin,xmax) ax.set_ylim(ymin,ymax) aspect=1.0*(ymax-ymin)/(xmax-xmin)*(ax.get_xlim()[1] - ax.get_xlim()[0]) / (ax.get_ylim()[1] - ax.get_ylim()[0]) ax.set_aspect(aspect) plt.savefig(fnameF,dpi=200) plt.show() plt.close()