爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 14559|回复: 16

[作图] panel怎么去掉图之间的空白啊?

[复制链接]
发表于 2014-9-23 17:24:42 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
用panel画分图,已经在panel的设置中写了 presources@gsnPanelYWhiteSpacePercent = 0.0,可没有任何反应。
图之间的距离没有变化。先忽略我画的很丑的图,写得有点乱的程序。

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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.ncl"

begin
f=addfile("prelev.nc","r")
wks = gsn_open_wks("png","panel2013900")
u=f->u(:,22,:,:)
v=f->v(:,22,:,:)
uu=sqrt(u*u+v*v)
t=short2flt(f->t(:,22,:,:))
hgt=short2flt(f->z(:,22,:,:))
hgt=hgt/9.8
t=t-273.15
t@units="(C)"
copy_VarMeta(u,uu)
lat=f->latitude
lon=f->longitude
printMinMax(t,False)
printMinMax(hgt,False)
printMinMax(uu,False)
ntime=12
temp=new(ntime,graphic)
hgt1=new(ntime,graphic)
vec=new(ntime,graphic)

;`````````````````````````````````````````````````````````````````````
;map
;`````````````````````````````````````````````````````````````````````
resources2=True
resources2@gsnDraw                 = False
resources2@gsnFrame                = False
resources2@gsnRightString          =""
resources2@gsnLeftString           =""
; resources2@gsnMaximize           =True
resources2@mpMinLatF               = 10.
resources2@mpMaxLatF               = 30.
resources2@mpMinLonF               = 95.
resources2@mpMaxLonF               = 125.
resources2@mpFillOn                = False
resources2@mpOutlineOn             = False  ; Use outlines from shapefile
resources2@mpFillDrawOrder   = "PostDraw"
resources2@mpDataBaseVersion       = "MediumRes"
resources2@mpDataSetName           = "Earth..4"
resources2@mpOutlineOn           = True         ; Turn on map outlines
resources2@mpOutlineSpecifiers   = (/"China:states","Taiwan"/)      
;resources2@mpAreaMaskingOn = True   ;cover it
;resources2@mpMaskAreaSpecifiers = (/"China","Taiwan"/)   ;China:states
resources2@mpLandFillColor         = "white"
resources2@mpInlandWaterFillColor  = "white"
resources2@mpOceanFillColor        = "white"
resources2@mpOutlineBoundarySets   = "NoBoundaries"
; resources2@vpHeightF   = 1.2
; resources2@vpWidthF   = 0.4
; resources2@vpXF   = 0.1
; resources2@vpYF   = 0.9



;```````````````````````````````````````````````````````````````````
;contour
;```````````````````````````````````````````````````````````````````
resources2@cnFillOn                = True               
resources2@cnLinesOn               = False                        
resources2@cnInfoLabelOn           = False
resources2@cnLineLabelsOn          = False
resources2@gsnSpreadColors         = True         
resources2@lbLabelAutoStride       = True
resources2@lbLabelBarOn            = False
gsn_define_colormap(wks,"wh-bl-gr-ye-re") ;temp
resources2@gsnAddCyclic = False              ;not global
resources2@cnSmoothingOn = True
; resources2@cnLevelSelectionMode="ExplicitLevels"
; resources2@cnLevels             = (/-30,-20,-10,0,10,20/)
resources2@cnLevelSelectionMode="AutomaticLevels"
  resources2@tmYRLabelsOn         = False              ; no right labels
  resources2@tmYROn               = False     
  resources2@tmXTLabelsOn         = False              ; do not draw top labels
  resources2@tmXTOn               = False
  resources2@tmXBLabelsOn         = False              ; no bottom labels
  resources2@tmXBOn               = False              ; no bottom tickmarks
  resources2@tmYLLabelsOn         = False              ; do not draw left labels
  resources2@tmYLOn               = False              ; no left tickmarks
  resources2@tmXBLabelFontHeightF = 0.04
  resources2@tmYLLabelFontHeightF = 0.04
do i=0,11
;--Turn off various tickmarks and labels depend on which plot this is--
  if (i .ge. 8) then
    resources2@tmXBLabelsOn = True
    resources2@tmXBOn       = True
   else
    resources2@tmXBLabelsOn = False
    resources2@tmXBOn       = False
end if
if (i%4 .eq. 0) then
    resources2@tmYLLabelsOn = True
    resources2@tmYLOn       = True
   else
    resources2@tmYLLabelsOn = False
    resources2@tmYLOn       = False
  end if                                       
; resources2@gsnMaximize = True
temp(i)=gsn_csm_contour_map(wks,t(i,:,:),resources2)
; delete(resources2)

;````````````````````````````````````````````````````````````````````
;vector
;````````````````````````````````````````````````````````````````````
resources= True
; resources@gsnMaximize             = True
resources@gsnDraw                 = False
resources@gsnFrame                = False
resources@gsnRightString          = ""
resources@gsnLeftString           = ""
resources@tiMainFont="Times-Roman"
resources@gsnSpreadColors      = True          ; use full color map
resources@vcRefLengthF      = 0.1              ; ref vec length
;resources@vcGlyphStyle      = "WindBarb"         ; select wind barbs
resources@vcGlyphStyle = "CurlyVector"  ;和上面一行是两种不同的类型,自己选
resources@vcMinDistanceF          = 0.05              ; thin out windbarbs
; resources@vcRefMagnitudeF  = 2
resources@vcLineArrowColor     = "black"
resources@vcLineArrowHeadMaxSizeF = 0.02
resources@vcLineArrowThicknessF = 1.5
resources@tiXAxisString=""
if(i.eq.11) then
     resources@vcRefAnnoOn = True
   resources@vcRefAnnoOrthogonalPosF = -.26  ;vcref's position
   resources@vcRefAnnoFontHeightF =0.022 ;height
   else
     resources@vcRefAnnoOn = False
end if
vec(i)=gsn_csm_vector(wks,u(i,:,:),v(i,:,:),resources)
overlay(temp(i),vec(i))
; delete(resources)
;``````````````````````````````````````````````````
;contour
;````````````````````````````````````````````````
cnresources=True
cnresources@gsnDraw                 = False
cnresources@gsnFrame                = False
cnresources@gsnLeftString           = ""
cnresources@gsnRightString           = ""
; cnresources@gsnMaximize             = True
cnresources@cnInfoLabelOn           = False
cnresources@cnLineLabelsOn          = False
cnresources@cnMonoLineDashPattern   = True
cnresources@cnSmoothingOn = True
; cnresources@cnLevelSelectionMode="AutomaticLevels"
cnresources@cnLevelSelectionMode="ExplicitLevels"
cnresources@cnMinLevelValF=578
cnresources@cnMaxLevelValF=1128
cnresources@cnLevelSpacingF=20
;cnresources@cnLinePatterns          =  1
cnresources@tiMainString =""
hgt1(i)=gsn_csm_contour(wks,hgt(i,:,:),cnresources)
; delete(cnresources)
overlay(temp(i),hgt1(i))

;draw(temp(i))
;frame(wks)
end do
presources=True
presources@gsnMaxmize = True
presources@gsnPanelLabelBar = True ;add common colorbar
; presources@gsnPanelLeft               = 0.02   ; Leave room for leftmost label
presources@lbLabelFontHeightF = 0.014
presources@gsnPanelXWhiteSpacePercent = 0.0    ; remove all white space
presources@gsnPanelYWhiteSpacePercent = 0.0
presources@vcRefAnnoOn = True
gsn_panel(wks,temp,(/3,4/),presources)

draw(temp)
frame(wks)
end

panel2013900.000001.png
密码修改失败请联系微信:mofangbao
发表于 2014-9-23 17:49:26 | 显示全部楼层
通过看panel debug里面的标准坐标信息,调整X,Y的位置。
密码修改失败请联系微信:mofangbao
发表于 2014-9-23 21:11:58 | 显示全部楼层
;panel plot   ;所有图画在一张图上
   pres               =True

   pres@gsnPanelFigureStrings= (/"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"/)  
   pres@amJust   = "BottomLeft"
;   pres@gsnPanelScalePlotIndex          = 3
;   pres@pmLabelBarOrthogonalPosF        =0.005
   pres@gsnPanelFigureStringsFontHeightF=0.01   
   pres@gsnPanelXWhiteSpacePercent      =0.0
   pres@gsnPanelYWhiteSpacePercent      =0
   pres@gsnPanelLabelBar        =True
   pres@lbOrientation       ="Vertical"
   pres@pmLabelBarHeightF     =0.5
   pres@lbLabelStride         = 1
   pres@gsnPanelScalePlotIndex     = 7
   pres@gsnPanelLeft               = 0.1
   pres@gsnPanelRight              = 0.95
;  drawNDCGrid(wks1)
   pres@txFontHeightF = 0.01
   gsn_text_ndc(wks1,"x10~S~-3",0.92,0.76,pres)
  
   gsn_panel(wks1,plot,(/4,3/),pres)
这是我画的,也是十二个图,不过是四行三列,我之前把它弄成三行四列也出现空隙了。弄成四行三列就没有,具体什么原因我也没搞清楚,可以参考一下
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-23 22:24:23 | 显示全部楼层
风往北吹 发表于 2014-9-23 17:49
通过看panel debug里面的标准坐标信息,调整X,Y的位置。

你好,谢谢指点。 我看例子里面这样写的:pnlres@txString   = "Adjust X position of rightmost plots"
  pnlres@gsnPanelXF = (/-1,.53,-1,.53/)    ; Adjust rightmost plots
  gsn_panel(wks,plots,(/2,2/),pnlres)

  pnlres@txString   = "Adjust Y position of bottommost plots"
  pnlres@gsnPanelYF = (/-1,-1,.48,.48/)      ; Adjust bottommost plots.
我想问一下gsnPanelXF = (/-1,.53,-1,.53/) 这里的数组是按什么顺序排的呀?XF和YF一样吗?
另外通过设置panel debug打印出来的结果里面写着:(0)        -------min/max X,Y viewport positions for plots-------
(0)        min/max x viewport position = 0.0441484/0.794148
(0)        min/max y viewport position = 0.43142/0.743862
(0)        gsnPanelInvsblLeft = -4.47035e-08
(0)        -------min/max NDC values for all objects in panel-------
(0)        min/max x position = -4.46453e-08/1
(0)        min/max y position = 0.234421/0.749954
请问上面和下面这两种position的区别是什么呀?
非常感谢!我刚刚自己试了一下,结果头还是没有调整,我想估计是理解有误。
密码修改失败请联系微信:mofangbao
发表于 2014-9-23 22:43:11 | 显示全部楼层
坐等大神解救{:eb303:}{:eb303:}{:eb303:}{:5_275:}{:5_275:}
密码修改失败请联系微信:mofangbao
发表于 2014-9-23 23:21:35 | 显示全部楼层
甜果果 发表于 2014-9-23 22:24
你好,谢谢指点。 我看例子里面这样写的:pnlres@txString   = "Adjust X position of rightmost plots"
...

你的ncl是哪一个版本的?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-24 09:18:33 | 显示全部楼层
threetee 发表于 2014-9-23 21:11
;panel plot   ;所有图画在一张图上
   pres               =True

谢谢 的确很有用 我按照你的调成了4*3之后 也没什么空隙了
看来还是要自己慢慢来调
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-24 10:05:41 | 显示全部楼层
风往北吹 发表于 2014-9-23 23:21
你的ncl是哪一个版本的?

6.2.1的版本
密码修改失败请联系微信:mofangbao
发表于 2014-9-24 11:28:30 | 显示全部楼层
甜果果 发表于 2014-9-24 09:18
谢谢 的确很有用 我按照你的调成了4*3之后 也没什么空隙了
看来还是要自己慢慢来调

恩, 多试试总会有点收获,只是为什么四行三列就不行真的搞不明白是什么原因了,可能是总的纸张大小和每个图的大小的问题吧
密码修改失败请联系微信:mofangbao
发表于 2014-9-25 15:18:06 | 显示全部楼层
threetee 发表于 2014-9-23 21:11
;panel plot   ;所有图画在一张图上
   pres               =True

  pres@gsnPanelScalePlotIndex     = 7改这一句的数值吧!改成大图中的小图(需要小图的四周没有units,title,long_name,经纬度坐标,意思就是要裸图的样子的)在大图中的第几个,从0开始!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表