matplotlib 画图

基本上2维点线图这些就够了

import matplotlib.pyplot as Plt
from  matplotlib.mlab import *
import numpy as Mm

######################## cycle

clour=[‘-‘,’-.’,’–‘,’k-‘,’:’]
age=[0.2,0.3,0.4,0.5,0.6]
length=Mm.size(age)
print length
for i in range(0,length):
sedname=’dust_forgrasil_11_newz_’+str(age[i])+’Gyr.data’
sed=load(sedname)
lam=sed[:,0]
flux=sed[:,1]
Plt.plot(lam,flux,clour[i])

############  log
y1=Mm.log10(data1[:,2]*(10**(-9)))

############# load

sed=load(‘dust_forgrasil_11_newz_0.5Gyr.data’)
lam=sed[:,0]
flux=sed[:,1]
################## figure

Plt.figure(1)
a=Plt.subplot(111)

################## text
Plt.text(0.5, Mm.log10(220),’SFR=200 M$_\odot$’,color=’r’)
################# plot
Plt.plot(lam,flux,’k-‘,linewidth=2)

########### plot line
Plt.axhline(y=sfry,color=’r’)
Plt.axvline(y=sfry,color=’r’)

############## plot error
rroryup=data1[0:14,2]
errorylow=data1[0:14,3]

Plt.errorbar(data1[0:14,0]/(1+z),data1[0:14,1]/(1+z),yerr=[errorylow, erroryup],xerr=0,fmt=’ko’)

######## axies

Plt.xlabel(r’$\lambda_{rest}$ [$\mu$m]’,fontsize=20,fontweight=’bold’)
Plt.ylabel(r’$F_{\nu}$ [$\mu$Jy]’,fontsize=20,fontweight=’bold’)
Plt.legend((‘0.2Gyr’,’0.3Gyr’,’0.4Gyr’,’0.5Gyr’,’0.6Gyr’),2)

Plt.ylim((1e-2 ,1e4))

a.set_xscale(“log”)
a.set_yscale(“log”)
Plt.savefig(“paper_age.eps”)

Plt.show()

类别:

28,479回应

发表回复