DKRZ NCL panel example#
DKRZ NCL script:
;---------------------------------------------------------------
; DKRZ - NCL Example: NCL_panel.ncl
;
; Description: draw a panel plot - 3 rows x 2 columns
;
; 01.07.2015 kmf
;---------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
;-- generate an ny x nx array of random data
nx = 100
ny = 100
data = generate_2d_array(15,15,240.,310.,0,(/ny,nx/))
;-- generate 1D lat/lon coord arrays and attach to data
lat = fspan(-90,90,ny)
lon = fspan(-180,180,nx)
data!0 = "lat"
data!1 = "lon"
data&lat = lat
data&lon = lon
data&lat@units = "degrees_north"
data&lon@units = "degrees_east"
;-- fill areas
fill_specs = (/"water","land"/)
;-- mask areas
mask_specs = (/\
"algeria","angola","angola-exclave-called-cabinda","benin","botswana",\
"burundi","cameroon","central-african-republic","chad","congo","djibouti",\
"egypt","equatorial-guinea","ethiopia","gabon","gambia","ghana","guinea",\
"guinea-bissau","ivory-coast","kenya","lesotho","liberia","libya",\
"madagascar","malawi","mali","mauritania","mauritius","morocco",\
"mozambique","namibia","niger","nigeria","rwanda","senegal","sierra-leone",\
"somalia","south-africa","sudan","swaziland","tanzania","togo","tunisia",\
"uganda","upper-volta","western-sahara","zaire","zambia","zimbabwe"/)
color_map = (/(/1.00,1.00,1.00/),(/0.00,0.00,0.00/),(/0.70,0.70,0.70/), \
(/0.75,0.50,1.00/),(/0.50,0.00,1.00/),(/0.00,0.00,1.00/), \
(/0.00,0.50,1.00/),(/0.00,1.00,1.00/),(/0.00,1.00,0.60/), \
(/0.00,1.00,0.00/),(/0.70,1.00,0.00/),(/1.00,1.00,0.00/), \
(/1.00,0.75,0.00/),(/1.00,0.38,0.38/),(/1.00,0.00,0.38/), \
(/1.00,0.00,0.00/)/)
;-- open a workstation
wks = gsn_open_wks("png","plot_panel")
gsn_define_colormap(wks,color_map)
;-- set resources
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnMaximize = True
res@gsnAddCyclic = False
res@cnFillColors = (/3,4,5,6,8,9,10,11,12,13,14,15/)
res@cnFillOn = True
res@cnFillDrawOrder = "Predraw"
res@cnLineDrawOrder = "Predraw"
res@cnHighLabelsOn = False
res@cnInfoLabelOn = False
res@cnLineLabelsOn = False
res@cnLowLabelsOn = False
res@mpProjection = "Orthographic"
res@mpEllipticalBoundary = True
res@mpCenterLatF = 10.0
res@mpCenterLonF = -95.0
res@mpGridAndLimbOn = True
res@mpGridSpacingF = 10
res@mpGridLineColor = 2
res@mpGridLineThicknessF = 1.1
res@mpGridMaskMode = "MaskLand" ;-- don't draw grid over land
res@mpLandFillColor = 2 ;-- gray
res@lbLabelBarOn = False ;-- turn off individual cb's
plot = new(6,graphic) ;-- assign graphic array
;-- plot 0
plot(0) = gsn_csm_contour_map(wks,data,res)
;-- plot 1
res@mpCenterLatF = 25.0
res@mpCenterLonF = 16.0
plot(1) = gsn_csm_contour_map(wks,data,res)
;-- plot 2
res@mpFillBoundarySets = "NoBoundaries"
res@mpAreaMaskingOn = 1
res@mpMaskAreaSpecifiers = mask_specs
res@mpFillAreaSpecifiers = fill_specs
plot(2) = gsn_csm_contour_map(wks,data,res)
;-- plot 3
res@cnFillDrawOrder = "PostDraw"
res@cnLineDrawOrder = "PostDraw"
plot(3) = gsn_csm_contour_map(wks,data,res)
;-- plot 4
res@cnFillDrawOrder = "Draw"
res@cnLineDrawOrder = "Draw"
plot(4) = gsn_csm_contour_map(wks,data,res)
;-- plot 5
res@cnFillDrawOrder = "PreDraw"
res@cnLineDrawOrder = "PreDraw"
res@mpSpecifiedFillColors = (/7,2/)
plot(5) = gsn_csm_contour_map(wks,data,res)
;-- panel resources
pres = True
pres@gsnPanelCenter = True
pres@gsnPanelScalePlotIndex = 1
pres@gsnPanelLabelBar = True ;-- add common colorbar
pres@lbLabelFontHeightF = 0.01 ;-- make labels smaller
pres@lbOrientation = "Vertical"
pres@lbBoxCount = 14
pres@lbLabelFont = "Helvetica-bold"
pres@lbLabelAlignment = "BoxCenters"
pres@lbLabelStrings = (/"Ocean","Land","< 0","0-10","10-20","20-30", \
"30-40","40-50","50-60","60-70","70-80", \
"80-90","90-100","> 100"/)
pres@lbFillColors = (/7,2,3,4,5,6,8,9,10,11,12,13,14,15/)
pres@pmLabelBarOrthogonalPosF = 0.02 ;-- move labelbar to the right
pres@txString = "PreDraw, Draw, PostDraw, Mask"
;-- draw the panel
gsn_panel(wks,plot,(/3,2/),pres)
end
Result: