利用python画图
来源:互联网 发布:java中间件 pdf 编辑:程序博客网 时间:2024/06/08 10:06
#!/usr/bin/env python# coding=utf-8import numpy as npimport matplotlib.pyplot as pltplt.rcParams['figure.figsize'] =8, 5#plt.rcParams['figure.dpi'] =600plt.rcParams['savefig.dpi'] = 600plt.rcParams['font.family'] = 'serif'rho=1000n=12D=0.3052crp6= np.loadtxt("./openwatercrp4.txt",usecols=(0,1,2,3,4,5,6),unpack='true')plt.plot(crp6[0],crp6[1], \ color='r',marker='',markevery=20,markerfacecolor='none',markeredgecolor='r', \ markersize=8,lw=2,linestyle='-',label='$K_T(CFD)$')plt.plot(crp6[0],crp6[2], \ color='k',marker='s',markerfacecolor='none',markeredgecolor='k', \ markersize=8,lw=2,linestyle='',label='$K_T(EFD)$')plt.plot(crp6[0],crp6[3], \ color='k',marker='',markevery=20,markerfacecolor='none',markeredgecolor='k', \ markersize=8,lw=2,linestyle='-',label='$10K_Q(CFD)$')plt.plot(crp6[0],crp6[4], \ color='k',marker='v',markerfacecolor='none',markeredgecolor='k', \ markersize=8,lw=2,linestyle='',label='$10K_Q(EFD)$')plt.plot(crp6[0],crp6[5], \ color='b',marker='',markevery=20,markerfacecolor='none',markeredgecolor='b', \ markersize=8,lw=2,linestyle='-',label='$\eta_0(CFD)$')plt.plot(crp6[0],crp6[6], \ color='b',marker='o',markerfacecolor='none',markeredgecolor='b', \ markersize=8,lw=2,linestyle='',label='$\eta_0(EFD)$')#plt.plot((front[0]-0.6)/0.08333,(-front[1]-front[2])/(rho*pow(n,2)*pow(D,4)),\# color='b',marker='',markevery=20,markerfacecolor='none',markeredgecolor='r',\# markersize=8,lw=2,linestyle='-',label='$K_T(Single)$')###plt.plot((front[0]-0.6)/0.0833,-10*(front[3]+front[4])/(rho*pow(n,2)*pow(D,5)),\# color='b',marker='',markevery=20,markerfacecolor='none',markeredgecolor='k',\# markersize=8,lw=2,linestyle='-',label='$10K_T(Single)$')###plt.plot((crp[0]-0.6)/0.083333,(-crp[1]-crp[2])/(rho*pow(n,2)*pow(D,4)),color='k',\# marker='',markevery=20,markerfacecolor='none',markeredgecolor='k',markersize=8,\# lw=2,linestyle='--',label='$K_T(CRPs)$')###plt.plot((crp[0]-0.6)/0.083333,-10*(crp[3]+crp[4])/(rho*pow(n,2)*pow(D,5)),color='k',\# marker='',markevery=20,markerfacecolor='none',markeredgecolor='k',markersize=8,\ #lw=2,linestyle='--',label='$10K_T(CRPs)$')##for tick in ax.xaxis.get_major_ticks():# tick.label.set_fontsize(50)#plt.plot.set_xlabel(fontsize=50)#plt.ylim([-1,2])#plt.xlim([0,200])#plt.xlabel("T/(s)", size=12,fontsize=50)#plt.ylabel("Wave elevation (m))", size=12)plt.grid()plt.legend(fancybox=True,handlelength=3,fontsize=8,ncol=3)#plt.subplot(2,1,2)#plt.plot(x-1.3,y,color='b',lw=2,linestyle='--',label='Theoretical waveform')#plt.plot(x1,y1*0.99,color='black',lw=2,linestyle='-', label='Numerical waveform')#plt.hlines(y2,0,300,color='black',linestyle='-.')#plt.hlines(y3,0,300,color='grey',linestyle='-.',label='Wave crest and trough')#plt.plot(y=y3,color='grey',linestyle='-.')plt.xlabel("$J$", size=16)plt.ylabel("$K_T,10K_Q, \eta_0$", size=16)#plt.ylabel("$K_T,10K_Q,\eta_0$", size=16)plt.xlim([0.68,1.12])plt.ylim([0.1,1])plt.grid()plt.legend(loc='upper center',fancybox=False,ncol=3,handlelength=2,fontsize=12)#plt.legend(loc='upper center',bbox_to_anchor=(0.5,0.5),fancybox=False,ncol=3,handlelength=2,fontsize=13)plt.tight_layout()plt.savefig('./owcrp4.png')plt.show()
阅读全文