- 积分
- 11863
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-9-17
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 Quincy 于 2016-4-9 20:38 编辑
本科主要学的是GrADS,现在做毕业论文主要用NCL来画图,经验积累中。。。
——————————————我是分割线——————————————————————————————————
利用panel画1行2列的垂直剖面图,中间有一片空白,导致右侧的坐标无法显示。
解决方法:
NCL官网有一个脚本(https://www.ncl.ucar.edu/Applications/Scripts/panel_20.ncl)
其中有一段是这样说的:
; Maximize plots in frame.; psres = True maximize_output(wks,psres) ; calls draw and frame for you ;; If you try to use gsn_panel to panel different sized plots, you; will get unexpected results. You can turn on gsnPanelDebug to; see what viewport values are used, and then use these values; to set the viewport resources for each individual plot.; pnlres = True; pnlres@gsnPanelDebug = True ; Use to print values for position, width, ; and height.; gsn_panel(wks,(/xy0,xy1,cn0,cn1/),(/2,2/),pnlres)
然后改用maximize_output命令就可以啦~
最后,把画这个图的代码贴出来~
图形还有一些需要优化的地方(比如右边的Y轴的Labels想自己设置成4,6,8,12,但总是不成功,每次出来都是7和14(⊙﹏⊙))请各位大神指教~!
;Print Pictures For linear.t42l20.carbon3.nc
;Revised by QX,2016/04/09
; =================================================;
;--load function/procedure library
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/contrib/cd_string.ncl"
; =================================================;
begin
fname = "/home/lbmwork/data/Carbon3/linear.t42l20.carbon3.nc"
fin = addfile(fname,"r")
U = fin->u
V = fin->v
W = fin->w
U&lev@units = "hPa"
V&lev@units = "hPa"
; Omega is significantly smaller than v, so we will scale it so that some vertical motion is visible.
wscale = W*(-1000.)
copy_VarCoords(W, wscale) ; copy coordinate variables
;---Create plot
wks = gsn_open_wks ("png", "vector_CHECK" )
res = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@cnFillOn = False
res@cnInfoLabelOn = False
res@cnFillPalette = "BlAqGrYeOrReVi200"
res@cnLevelSelectionMode = "ManualLevels"
res@cnLevelSpacingF = 5.0
res@cnMinLevelValF = -50.
res@cnMaxLevelValF = 50.
res@gsnDraw = False
res@gsnFrame = False
res@gsnMaximize = False
res@gsnLeftString = ""
res@gsnRightString = ""
res@lbLabelBarOn = False
res@lbLabelAutoStride = True
res@pmTickMarkDisplayMode = "Always"
res@tiMainString = "(96~S~o~N~E)"
res@tiYAxisString = "Pressure(hPa)"
res@tmYRMode = "Automatic" ; turn off special labels on right axis
res@tmYUseLeft = False ; Make right axis independent of left
res@tmYLOn = True ; Turn on left tickmarks
res@tmYROn = False ; Turn off right tickmarks
res@tmYLLabelsOn = True
res@tmYRLabelsOn = False
res@trYMinF = 100
res@trYMaxF = 1000
res@tmXBMode = "Explicit"
res@tmXBValues = (/-30,0,30/)
res@tmXBLabels = (/"30~S~o~N~S","0~S~o~N","30~S~o~N~N"/)
res@vcGlyphStyle = "CurlyVector" ; turn on curly vectors
res@vcMapDirection = False
res@vcRefAnnoOn = True
res@vcRefAnnoString1 = "0.05"
res@vcRefMagnitudeF = 0.05 ; add a reference vector
res@vcRefLengthF = 0.05 ; what the ref length is
res@vcRefAnnoSide = "Bottom"
res@vcRefAnnoString2On = False
res@vcRefAnnoPerimOn = True
res@vcRefAnnoArrowEdgeColor = "black"
res@vcRefAnnoOrthogonalPosF = -0.15
res@vcRefAnnoParallelPosF = 0.999
res@vcRefAnnoBackgroundColor = "White"
res@vcVectorDrawOrder = "PostDraw"
res@vpWidthF = 0.40
res@vpHeightF = 0.40
res@vpXF = 0.1
res@vpYF = 0.75
;---Draw plot from pole to pole at 96E
plot1 = gsn_csm_pres_hgt_vector(wks,U(15,:,{-60:60},{96}),V(15,:,{-60:60},{96}),wscale(15,:,{-60:60},{96}),res )
res@tiYAxisOn = False
res@tiMainString = "(31~S~o~N~N)"
res@tmXBMode = "Explicit"
res@tmXBValues = (/90,135,180/)
res@tmXBLabels = (/"90~S~o~N~E","135~S~o~E","180~S~o~N~E"/)
delete(res@tmYRMode)
res@tmYLOn = False ; Turn on left tickmarks
res@tmYROn = True ; Turn off right tickmarks
res@tmYLLabelsOn = False
res@tmYRLabelsOn = True
res@vpXF = 0.52
res@lbLabelAutoStride = True
plot2 = gsn_csm_pres_hgt_vector(wks,V(15,:,{31},{45:180}),U(15,:,{31},{45:180}),wscale(15,:,{31},{45:180}),res )
add_T = "JJA"
x = 0.5 ; middle of x
y = 0.85 ; towards top of page
txres = True
txres@txFontHeightF = 0.03
gsn_text_ndc(wks,add_T,x,y,txres)
psres = True
maximize_output(wks,psres)
end
|
-
出现问题的图
-
修改之后
|