⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xy_25.ncl

📁 ncl脚本程序
💻 NCL
字号:
;****************************************************; xy_25.ncl;; Concepts illustrated:;   - Drawing an XY plot with two different Y axes;   - Adding curves to an existing XY plot;   - Removing trailing zeros from tickmark labels;   - Maximizing plots after they've been created;;****************************************************load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"   ;****************************************************begin;***************************; read in data;***************************  f    = addfile ("TestData.xy3.nc" , "r")  t0   = f->T(0,0:35)                 ; read in left variable  t1   = f->T(2,0:35)  p0   = f->P(0,0:35)                 ; read in right variable  p1   = f->P(1,0:35)                 ; read in data for extra curve  pmin = min((/p0,p1/))             ; Get min/max so we can set limits  pmax = max((/p0,p1/))             ; of axes in advance.  tmin = min((/t0,t1/))  tmax = max((/t0,t1/))  time = f->time(0:35)              ; this is our x  wks = gsn_open_wks("ps","xy") ; resources for "left" variable  resL                  = True   resL@gsnMaximize      = True  resL@vpWidthF         = 0.8            ; Change the aspect ratio, but   resL@vpHeightF        = 0.4            ; make plot as large as possible.  resL@trYMinF          = tmin           ; Set min/max of left Y axis  resL@trYMaxF          = tmax  resL@xyLineColor      = "Brown"  resL@xyLineThicknessF = 2.5  resL@tiYAxisFontColor = resL@xyLineColor; resources for "right" variable  resR                  = True                        resR@trYMinF          = pmin           ; Set min/max of right Y axis  resR@trYMaxF          = pmax  resR@xyLineColor      = "NavyBlue"  resR@xyDashPattern    = 2              ; Dashed line for 2nd curve  resR@xyLineThicknessF = 2.5  resR@tiYAxisFontColor = resR@xyLineColor  resR@tmYRFormat       = "f"            ; Remove trailing zeros from labels  plot = gsn_csm_xy2(wks,time,t0,p0,resL,resR);; Create data object to add new curve to right axis.;  dataid = create "xyData" coordArraysClass defaultapp    "caYArray": p1    "caXArray": time  end create;; Add new data object plot represented by right axis.;; Use the attribute "xy2" returned from gsn_csm_xy2.;  dataspec = NhlAddData(plot@xy2,"xyCoordData",dataid); Set some resources for new curve.  setvalues dataspec    "xyLineColor"      : resR@xyLineColor    "xyLineThicknessF" : resR@xyLineThicknessF    "xyDashPattern"    : 7         ; use different dashed line  end setvalues   psres = True  maximize_output(wks,psres)      ; Maximize new plots in frame.end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -