| 
 
	积分2979贡献 精华在线时间 小时注册时间2015-3-17最后登录1970-1-1 
 | 
 
| 
我想画三张图拼一块儿,并且上下两图共用X轴,左右两图共用Y轴,主要利用的语句是 gsn_attach_plots.分别画上下,左右,都能得到正确的图形(图1 图2),但是想一块儿画的时候,图就不太对了(图3)。
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  尝试过设置视图VP大小,但是都没有效果。
 
 脚本如下
 
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
 ;先试试冬季的
 ;city 风向风速频率 2点 14点
 begin
 month= new(6,string)
 month=(/"1","2","3","12","12_1_2","12_1_2_3"/)
 monthname= new(6,string)
 monthname=(/"January","February","March","December","Winter(DJF)","DJFM"/)
 time=new(2,string)
 
 
 
 
 fname="D:/WR/awsnew/data/city_wind_fre/2/1_city_winddir_fre.txt"
 data =asciiread(fname,(/15,18/), "float")
 ;注意gsn_csm_contour 画二维 Y轴的在左边维
 fre  =new((/17,6/),float)   ;Y轴是风向 17个点0 360
 fre_sum=new(6,float)
 fre_dir=new(17,float)
 do i=0,5
 fre(0:16,i)=data(i,1:17)
 fre_sum(i)=sum(fre(0:16,i))
 end do
 do m=0,16
 fre_dir(m)=sum(fre(m,:))
 end do
 
 wks_type="png"
 wks_type@wkWidth=4500
 wks_type@wkHeight=4500
 
 wks=gsn_open_wks(wks_type,"D:/WR/awsnew/Ave/city_wind_dir_fre/2/2xy/1_try")
 ;--------------------共同属性
 res                         = True
 res@gsnDraw                 = False
 res@gsnFrame                = False
 
 res@tmXBLabelDeltaF = -0.5                       ;使其更靠近X轴
 res@tmYLLabelDeltaF = -0.5
 res@tmXBMajorLengthF = 0.01                      ;刻度线长短
 res@tmYLMajorLengthF = 0.01
 res@tmXBMajorThicknessF = 5.0
 res@tmYLMajorThicknessF = 5.0
 res@tmXBLabelFontHeightF = 0.02                 ;字体大小
 res@tmYLLabelFontHeightF = 0.02
 res@tmXBLabelFontThicknessF = 3
 res@tmYLLabelFontThicknessF = 3
 res@tmBorderThicknessF     = 5
 res@tmYLPrecision   =2
 
 ;--------------------res1 xy
 res1=res
 res1@tmXBLabelsOn   = True                        ;打开tickMark的开关,否则后面设置的一系列都没有用!
 res1@tmYLLabelsOn   = True
 res1@tmXBMode        ="Explicit"
 res1@tmXBValues      =(/0,1,2,3,4,5,6/)
 res1@tmXBLabels      =(/"0","1","2","3","4","5","6"/)
 
 res1@tiYAxisString           ="frequency(%)"
 res1@xyLineThicknessF        =10
 res1@xyDashPattern           =0
 res1@vpXF=0.05
 res1@vpYF=0.9
 res1@vpHeightF           =0.2  ;设置显示高度
 res1@vpWidthF            =0.5
 base_plot=gsn_csm_y(wks,fre_sum,res1)    ;绘图命令()
 
 ;--------------------res2 风向风速频率
 res2=res
 res2@tmXBLabelsOn   = True                        ;打开tickMark的开关,否则后面设置的一系列都没有用!
 res2@tmYLLabelsOn   = True
 res2@tmXBMode        ="Explicit"
 res2@tmXBValues      =(/0,1,2,3,4,5,6/)
 res2@tmXBLabels      =(/"0","1","2","3","4","5","6"/)
 
 res2@tiYAxisString           ="wind direction(~S~o~N~)"
 res2@cnFillOn               = True              ;--设置填色
 res2@cnLinesOn              = True              ;--不画等值线
 res2@cnLineLabelsOn         = False              ;--不显示等值线数值
 res2@cnSmoothingOn          = True               ;--平滑线条
 res2@cnLevelSelectionMode ="ExplicitLevels"
 res2@cnLevels =(/1.0,2.0,3.0,4.0,5.0/)
 res2@cnExplicitLabelBarLabelsOn = True
 res2@vpXF=0.05
 res2@vpYF=0.7
 res2@vpHeightF           =0.5  ;设置显示高度
 res2@vpWidthF            =0.5
 
 ;坐标轴
 res2@lbOrientation          = "Horizontal"       ;--设置色标方向,水平或垂直
 res2@lbBoxLinesOn          = True                ;--关闭lbar box 线条 ,数字越大色标越靠下
 res2@tmYLMode        ="Explicit"
 res2@tmYLValues      =(/0,2,4,6,8,10,12,14,16/)
 res2@tmYLLabels      =(/"0","45","90","135","180","225","270","315","360"/)
 res2@lbLabelBarOn = True       ;LabelBar显示
 res2@lbLabelStrings = (/"1.0","2.0","3.0","4.0","5.0"/)
 res2@pmLabelBarHeightF=0.1
 
 res2@gsnAttachPlotsXAxis       =True
 plot2=gsn_csm_contour(wks,fre,res2)
 
 ;res3 右侧 xy图
 y=fspan(0,360,17)
 y!0="direction"
 res3=res
 res3@trXMinF=0
 res3@tmXBMinorOn =False
 res3@tmXBMode        ="Explicit"
 res3@tmXBValues      =(/2,4,6,8,10,12/)
 res3@tmXBLabels      =(/"2","4","6","8","10","12"/)
 res3@gsnCenterString="frequency(%)"
 res3@xyLineThicknessF        =10
 res3@xyDashPattern           =0
 res3@vpWidthF                =0.2  ;设置显示宽度
 res3@gsnAttachPlotsXAxis       =False
 res3@vpYF=0.7
 res3@vpHeightF           =0.5  ;设置显示高度
 res3@vpWidthF            =0.2
 
 plot3=gsn_csm_xy(wks,fre_dir,y,res3)    ;绘图命令()
 
 plot=gsn_attach_plots(base_plot,(/plot2/),res1,res2)
 plotadd=gsn_attach_plots(plot2,(/plot3/),res2,res3)
 delete(fname)
 delete(data)
 delete(fre)
 draw(base_plot)
 frame(wks)
 
 end
 
 
 
 
 | 
 |