现在不是那么烦NCL了,只是有一点烦,呵呵。
来自:http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/examples.shtml
以及http://blog.sina.com.cn/s/articlelist_1157087364_0_1.html
-------------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
;----------- 基本必备的设置-----------------------------------------
xwks = gsn_open_wks("x11","plot_name") ; Open an X11 workstation.
resources = True ; Indicate you want to set some
; resources.
;--------标题设定------------------
resources@tiMainString = "Temperature (C)" ; Create a title.
resources@tiMainString = pres@long_name
resources@tiMainFont = 26
resources@tiXAxisFont = 26
resources@tiYAxisFont = 26
;--------some useful settings-------------
res@gsnMaximize = True ; maximize plot in frame
res@cnFillMode = "MeshFill" ; for faster draw 网眼填充
;--------坐标轴设定------------
resources@tiXAxisString = lon@long_name ;x name
resources@tiYAxisString = lat@long_name ;y name 注意这个@long_name的用法,很实用
resources@sfXArray = lon ;指定X轴的变量
resources@sfYArray = lat
;-----------填色----------------------------------------
resources@cnMonoLineColor = False ; Turn off the drawing of
; contours lines in one color.
resources@cnFillOn = True ; Turn on contour line fill.
res@cnFillDrawOrder = "PreDraw" ; draw contours first
resources@cnMonoFillPattern = False ; Turn off using a single fill
resources@cnMonoFillPattern = True ; Turn solid fill back on. ; pattern.
resources@cnMonoFillColor = True
resources@cnMonoFillColor = False ; Use multiple colors.
resources@cnMonoLineColor = True
;使用特定的Level值和配色方案对等值区间进行设置
res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels
res@cnLevels = (/-30.,-20.,-10.,0.,10.,20./) ; set levels
res@cnFillColors = (/5,6,7,8,9,10,11/) ; set the colors to be used
;---------- Contour line ------------------------------------------
resources@cnLineLabelsOn = False ; Turn off line labels.
resources@cnInfoLabelOn = False ; Turn off informational
; label.
resources@cnLinesOn = False ; Turn off contour lines. 等值线不显示
resources@pmLabelBarDisplayMode = "Always" ; Turn on label bar.
resources@lbPerimOn = False ; Turn off perimeter on
; label bar.
plot = gsn_contour(xwks,Z,resources) ; Draw a contour plot.
;---------- color map ------------------------------------------
;http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml
;---Using the color map to define colors for contours or vectors
res@cnFillPalette = "BkBlAqGrYeOrReViWh200"
res@vcLevelPalette = "BkBlAqGrYeOrReViWh200"
;---Reading the colormap into an N x 4 (RGBA) array
cmap = read_colormap_file("ncl_default")
;---Using the color map to define a color map for the workstation
gsn_define_colormap(wks,"BlueYellowRed")
;---define your own
cmap = (/(/0.,0.,0./),(/1.,1.,1./),(/.1,.1,.1/),(/.15,.15,.15/),\
(/.2,.2,.2/),(/.25,.25,.25/),(/.3,.3,.3/),(/.35,.35,.35/),\
(/.4,.4,.4/),(/.45,.45,.45/),(/.5,.5,.5/),(/.55,.55,.55/),\
(/.6,.6,.6/),(/.65,.65,.65/),(/.7,.7,.7/),(/.75,.75,.75/),\
(/.8,.8,.8/),(/.85,.85,.85/)/)
gsn_define_colormap(xwks,cmap) ; Define a new color map.
;-----------------总算能绘图了-----------------------------------------------------
plot = gsn_contour(xwks,pres,resources) ; Draw a contour plot.
;--------------叠加绘图的话------------------------------------------------------
gsn_csm_contour_map_overlay(wks,pdata,vdata,res,res2)
overlay(map,wplot) ;叠加plot给之前的map
draw(map)
delete(plot) ; Clean up.
delete(temp)
delete(resources)
end