参考文档:
href="http://www.cnblogs.com/vamei/archive/2012/09/17/2689798.HTML" rel="nofollow">matplotlib画饼状图
1. 图中加标注
2. 柱状图
<p >
3. colormap图
<p >
'+fn) #fn='/d3/MWRT/R20130805/F06925_EMS60.txt' data=wlab.dlmread(fn) EMS=EMS+List(data[:,1])#地表发射率 LST=LST+List(data[:,2])#温度 TBH=TBH+List(data[:,8])#水平亮温 TBV=TBV+List(data[:,9])#垂直亮温 #----------------------------------------------------------- #生成格点数据,利用grIDdata插值 grID_x,grID_y = np.mgrID[275:315:1,0.60:0.95:0.01] grID_z = grIDdata((LST,EMS),TBH,(grID_x,grID_y),method='cubic') #将横纵坐标都映射到(0,1)的范围内 extent=(0,1) #指定colormap cmap = matplotlib.cm.jet #设定每个图的colormap和colorbar所表示范围是一样的,即归一化 norm = matplotlib.colors.normalize(vmin=160,vmax=300) #显示图形,此处没有使用contourf #>>>ctf=plt.contourf(grID_x,grID_y,grID_z) gci=plt.imshow(grID_z.T,extent=extent,origin='lower',cmap=cmap,norm=norm) #配置一下坐标刻度等 ax=plt.gca() ax.set_xticks(np.linspace(0,9)) ax.set_xticklabels( ('275','280','285','290','295','300','305','310','315')) ax.set_yticks(np.linspace(0,8)) ax.set_yticklabels( ('0.60','0.65','0.70','0.75','0.80','0.85','0.90','0.95')) #显示colorbar cbar = plt.colorbar(gci) cbar.set_label('$T_B(K)$',Fontdict=Font) cbar.set_ticks(np.linspace(160,300,8)) cbar.set_ticklabels( ('160','180','200','220','240','260','300')) #设置label ax.set_ylabel('Land Surface Emissivity',Fontdict=Font) ax.set_xlabel('Land Surface Temperature(K)',Fontdict=Font) #陆地地表温度LST #设置Title TitleStr='$T_B$ for Freq = '+str(float(fp[1:-1])*0.01)+'GHz' plt.Title(TitleStr) figname=fp+'.png' plt.savefig(figname) plt.clf()#清除图形plt.show()print('ALL -> Finished OK')
4. 饼状图
import matplotlib.pyplot as pltquants: GDPlabels: country namelabels = []
quants = []
Read datafor line in file('../data/major_country_gdp'):
info = line.split()
labels.append(info[0])
quants.append(float(info[1]))
make a square figureplt.figure(1,figsize=(6,6))
For China,make the pIEce explode a bitdef explode(label,target='China'):
if label == target: return 0.1
else: return 0
expl = map(explode,labels)
colors used. Recycle if not enough.colors = ["pink","coral","yellow","orange"]
PIE Plota@R_502_6622@ct: format of "percent" string;plt.pIE(quants,explode=expl,colors=colors,labels=labels,a@R_502_6622@ct='%1.1f%%',pctdistance=0.8,shadow=True)
plt.Title('top 10 GDP CountrIEs',bBox={'facecolor':'0.8','pad':5})
plt.show()
以上是内存溢出为你收集整理的matplotlib画图全部内容,希望文章能够帮你解决matplotlib画图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)