You are here: Home / News & Events / Workshops and Trainings / NCL Workshops / Beispiele und Aufgaben Teil V - Mehrere Plots auf einer Seite (panel)
Info
Our docs have moved to https://docs.dkrz.de This portal will be shutdown as soon the last content is migrated.

Beispiele und Aufgaben Teil V - Mehrere Plots auf einer Seite (panel)

NCL Skripte zur Erzeugung von mehreren Plots auf einer einzigen Seite.

 

Einfacher Panel Plot:

begin

  f   = addfile("../../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@cnFillOn       =  True            ;-- enable color filled contours
  res@cnLineLabelsOn =  False           ;-- don't draw labels on contour lines

;-- create plots
  res@tiMainString   = "This is the 1st plot"     ;-- title string
  plotA = gsn_csm_contour_map(wks,var(0,:,:),res) ;-- create plot but don't draw

  res@tiMainString   = "This is the 2nd plot"     ;-- title string
  plotB = gsn_csm_contour_map(wks,var(9,:,:),res) ;-- create plot but don't draw

  res@tiMainString   = "This is the 3rd plot"     ;-- title string
  plotC = gsn_csm_contour_map(wks,var(19,:,:),res) ;-- create plot but don't draw

;-- create panel
  gsn_panel(wks,(/plotA,plotB,plotC/),(/3,1/),False) ;-- rows = 3 ; columns = 1

end

 

Panel Plot mit gemeinsamer Label Bar:

begin

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

;-- open a workstation
  wks = gsn_open_wks("png" ,"part_V_panel_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@cnFillOn             =  True            ;-- enable color filled contours
  res@cnFillPalette        = "BlWhRe"         ;-- choose colormap
  res@cnLineLabelsOn       =  False           ;-- don't draw labels on contour lines
  res@cnInfoLabelOn        =  False

  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@lbLabelBarOn         = False            ;-- don't draw a labelbar below each plot - yet

;-- create plot array with 3 elements

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

  do i=0,2
     res@gsnCenterString   = "t0"+(i+8)       ;-- center string
     plot(i) = gsn_csm_contour_map(wks,var((i+8),:,:),res)   ;-- create the plots and write it to the plot array
  end do

;-- panel plot resource settings

  pres                     =  True
  pres@gsnPanelTop         =  0.96            ;-- prevent to paint over tickmark labels
  pres@gsnPanelBottom      =  0.012           ;-- prevent to paint over tickmark labels
  pres@gsnPanelLabelBar    =  True            ;-- draw a common labelbar below last plot

  pres@lbLabelFontHeightF  =  0.007           ;-- reduce the labelbar font size

  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
  
;-- generate the panel and plot it:  (/3,1/), here 3 rows and 1 columns

  gsn_panel(wks,plot,(/3,1/),pres)        ;-- generate the panel and use panel resources pres

end

 

Für die Aufgabe:

part_V_Panel_simple.ncl

begin

  f   = addfile("../../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@cnFillOn       =  True            ;-- enable color filled contours
  res@cnLineLabelsOn =  False           ;-- don't draw labels on contour lines

;-- create plots
  res@tiMainString   = "This is the 1st plot"     ;-- title string
  plotA = gsn_csm_contour_map(wks,var(0,:,:),res) ;-- create plot but don't draw

  res@tiMainString   = "This is the 2nd plot"     ;-- title string
  plotB = gsn_csm_contour_map(wks,var(9,:,:),res) ;-- create plot but don't draw

  res@tiMainString   = "This is the 3rd plot"     ;-- title string
  plotC = gsn_csm_contour_map(wks,var(19,:,:),res) ;-- create plot but don't draw

;-- create panel
  gsn_panel(wks,(/plotA,plotB,plotC/),(/3,1/),False) ;-- rows = 3 ; columns = 1

end

 

 

 

Document Actions