You are here: Home / Services / Data Analysis and Visualization / Visualization / Software / NCL / examples / source_code / DKRZ NCL Workshop: panels

DKRZ NCL Workshop: panels

All panel exercises from the DKRZ NCL Workshop. Requirement: NCL version 6.2.0 and higher

 

1. Simple panel plot:

begin

  f   = addfile("$NCL_TUT/data/ECHAM5_OM_A1B_2001_0101-1001_2D.nc","r")
  var = f->tsurf

;-- open a workstation
  wks = gsn_open_wks("png" ,"part_V_simple_panel")

;-- plot resource settings
  res                      =  True
  res@gsnDraw              =  False           ;-- don't draw the plot - yet
  res@gsnFrame             =  False           ;-- don't advance the frame
  res@gsnAddCyclic         =  True            ;-- add cyclic point

  res@cnFillOn             =  True            ;-- enable color filled contours
  res@cnLineLabelsOn       =  False           ;-- don't draw labels on contour lines

;-- create plot array
  plot = new(3,graphic)                       ;-- assign empty plot array with 2 elements

;-- create plots
  res@tiMainString             = "This is the 1st plot"  ;-- draw a title on top of 1st plot
  plot(0) = gsn_csm_contour_map_ce(wks,var(0,:,:),res)   ;-- create the plots (only hold in the plot array)

  res@tiMainString             = "This is the 2nd plot"  ;-- don't draw a title on top of 2nd plot
  plot(1) = gsn_csm_contour_map_ce(wks,var(9,:,:),res)   ;-- create the plots (only hold in the plot array)

  res@tiMainString             = "This is the 3rd plot"  ;-- don't draw a title on top of 3rd plot
  plot(2) = gsn_csm_contour_map_ce(wks,var(19,:,:),res)  ;-- create the plots (only hold in the plot array)

;-- create and plot the panel plot:    rows = 3 ; columns = 1
  gsn_panel(wks,plot,(/3,1/),False)

end 

 

2. Panel plot with common labelbar:

begin

  f   = addfile("$NCL_TUT/data/ECHAM5_OM_A1B_2001_0101-1001_2D.nc","r")
  var = f->tsurf

;-- open a workstation
  wks = gsn_open_wks("png" ,"part_V_panel_attachment_one_labelbar")

;-- plot resource settings
  res                      =  True
  res@gsnDraw              =  False           ;-- don't draw the plot - yet
  res@gsnFrame             =  False           ;-- don't advance the frame
  res@gsnAddCyclic         =  True            ;-- add cyclic point

  res@cnFillOn             =  True            ;-- enable color filled contours
  res@cnLevelSelectionMode = "ManualLevels"   ;-- set manual contour levels, so that all 
                                              ;-- plots have the same labelbar colors/values
  res@cnMinLevelValF       =  220             ;-- contour level minimum
  res@cnMaxLevelValF       =  315             ;-- contour level maximum
  res@cnLevelSpacingF      =    5             ;-- contour level interval
  res@cnLineLabelsOn       =  False           ;-- don't draw labels on contour lines
  res@cnInfoLabelOn        =  False           ;-- don't draw labels on contour lines

  res@lbLabelBarOn         =  False           ;-- don't draw a labelbar below each plot

;-- create empty graphic plot array
  nplots = 3
  plot = new(nplots,"graphic")

;-- create the plots
   do i=0,nplots-1
     res@gsnCenterString   =  "t="+(i+8)          ;-- draw center string
     plot(i) = gsn_csm_contour_map_ce(wks,var((i+8),:,:),res)   ;-- create the plots and write it to the plot array
  end do

;-- panel resources
  pres                     =  True
  pres@gsnPanelTop         =  0.96             ;-- panel top position (y-value)
  pres@gsnPanelBottom      =  0.012            ;-- panel bottom position (y-value)
  pres@gsnPanelLabelBar    =  True             ;-- draw a common labelbar

  pres@pmLabelBarOrthogonalPosF = 0.0          ;-- don't move labelbar

  pres@txString            = "Panel:  3 rows x 1 column + common labelbar and title"  ;-- draw a common title on top
  pres@txFontHeightF       =  0.020            ;-- text font size
  pres@txPosXF             =  0.5              ;-- text x-position
  pres@txPosYF             =  0.97             ;-- text y-position
  pres@txJust              = "CenterCenter"    ;-- text justification

  gsn_panel(wks,plot,(/3,1/),pres)

end 

 

 

 

 

Document Actions