import numpy as np import matplotlib.pyplot as plt def DINP(fnameR): QQ=[] EL=[] fin=open(fnameR,'r') text=fin.readline() while 1: text=fin.readline() if not text: break text=text.strip() text=text.split() QQ=QQ+[float(text[0])] EL=EL+[float(text[1])] fin.close() return QQ,EL fnameF='fig_lt_HQ.png' fnameR1='out_XS76.txt' fnameR2='out_XS77.txt' # Input data QQ1=[] EL1=[] QQ2=[] EL2=[] QQ1,EL1=DINP(fnameR1) QQ2,EL2=DINP(fnameR2) # Parameter setting qmin=0.0;qmax=6000.0;dq=1000 emin=72.0;emax=86.0;de=2.0 fig=plt.figure() line1=plt.plot(QQ1,EL1,color='black',lw=2.0,label='XS.76 (i=0.001209)') line2=plt.plot(QQ2,EL2,color='black',lw=2.0,label='XS.77 (i=0.000656)') line1[0].set_dashes([5,2]) line2[0].set_dashes([8,4,2,4]) plt.xlabel('Discharge (m$^3$/s)') plt.ylabel('Elevation (EL.m)') plt.xlim(qmin,qmax) plt.ylim(emin,emax) plt.xticks(np.arange(qmin,qmax+dq,dq)) plt.yticks(np.arange(emin,emax+de,de)) plt.grid() plt.legend(shadow=True,loc='upper left',handlelength=3) plt.savefig(fnameF,dpi=200) plt.show() plt.close()