.brian & Verica:
NCL "tutorial"

Panel plot

Set up

  • Many of the functions and routines used for plotting are in the files called "gsn_code.ncl", "gsn_csm.ncl", "shea_util.ncl" and "contributed.ncl", which come along with the instalation of NCL. To use plotting functions one needs to first load these files.

    ; load necessary ncl files:
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"


  • To plot data, one first has to open a workstation where the plot will be framed. Workstation can be a frame on screen (x11) or a file (eps and epsi for one page, and ps and pdf for multiple pages). However, here we'll be working only with the x11 (screen).

    ; open workstation
    wks = gsn_open_wks("x11","panel-plot")

  • Prepare workstation to use color table instead of named colors
    ; define color table
    gsn_define_colormap(wks,"nrl_sirkes")

  • Define number of plots in the panel
    plot = new(3,graphic)

  • Plots can be made from data stored in files, or from calculated variables. For simplicity, here we use data stored in the file. NCL supports various formats of data. Here, we only provide examples of NetCDF format.

    ; open the file to read data from it
    fi2 = addfile("21600.g9.dws.nc","r")

    ; read in data
    ; 1. coordinates
    t = fi2->t
    x = fi2->x
    y = fi2->y

    ; 2. data
    w200 = fi2->w_200
    wcb = fi2->w_cb
    w750 = fi2->w_750


  • Customize plots
    res = True
    res@cnFillOn = True
    res@cnRasterModeOn = True
    res@cnLinesOn = False
    res@sfXArray = x/1.e3
    res@sfYArray = y/1.e3
    res@tiXAxisString = "x [km]"
    res@tiYAxisString = "y [km]"
    res@cnInfoLabelOn = False
    res@cnLevelSelectionMode = "ManualLevels"
    res@cnMinLevelValF = -1.5
    res@cnMaxLevelValF = 1.5
    res@cnLevelSpacingF = .3
    res@gsnSpreadColors = True
    res@gsnSpreadColorStart = 2
    res@gsnSpreadColorEnd = 22
    res@lbOrientation = "vertical"


Panel plot

    To plot a panel, first define individual plots, but without drawing and/or framing them in the workstaion:
    res@gsnDraw = False
    res@gsnFrame = False


  • Plotting can be quick with NCL automaticly choosing the settings:

    • Define the plots, but don't plot them
      plot(0) = gsn_csm_contour(wks,w200(dimsizes(t)-1,:,:),res)
      plot(1) = gsn_csm_contour(wks,wcb(dimsizes(t)-1,:,:),res)
      plot(2) = gsn_csm_contour(wks,w750(dimsizes(t)-1,:,:),res)


    • Basic panel
      gsn_panel(wks,plot,(/3,1/),False)

  • One can customize the plots to the publishing quality without too much effort, but lots of patience:

    • Adjust custimization of individual plots and define them
      ; turn off individual label bars
      res@lbLabelBarOn = False
      ; define the plots, but don't plot them
      plot(0) = gsn_csm_contour(wks,w200(dimsizes(t)-1,:,:),res)
      plot(1) = gsn_csm_contour(wks,wcb(dimsizes(t)-1,:,:),res)
      plot(2) = gsn_csm_contour(wks,w750(dimsizes(t)-1,:,:),res)


    • Customize panel by setting its resourses
      resP = True
      ; introduce a common title
      resP@txString = "Vertically oriented common label bar"
      ; turn on common label bar
      resP@gsnPanelLabelBar = True
      ; set its orientation
      resP@lbOrientation = "vertical"

    • Customized panel
      gsn_panel(wks,plot,(/3,1/),resP)