Trying to produce a Panel Plot

From: Helen Parish <hparish_at_nyahnyahspammersnyahnyah>
Date: Mon, 20 Apr 2009 01:52:21 -0700

I am trying to create a panel of plots similar to the one shown in (b)
below. I am hoping to save space by using the same color bar and axes
labels for all plots. I have tried to follow the suggestions on the
manual pages for how to do this, but they do not seem to work. The
difficulties I am having are as follows:

1) I have used "res_at_lbLabelBarOn = False" to turn
off individual color bars on each plot
                     and "resP_at_gsnPanelLabelBar = True" to
add a common color bar

Instead of turning off the individual color bars and putting a single
bar at the bottom of the panel, this changes the way the levels are
marked from using a color bar to having the numbers written on the
plot, as can be seen by comparing the original plot in (b) below, and
the resulting panel in (c). This not the style that I wanted, and this
also adds an extra description under each plot, which takes up
unnecessary space, and which is too small to be legible. What I wanted
to do was put a single color bar under the whole panel plot, but this
does not seem to work.

2). I want an overall title for the panel. I attempted to put this in
using :
         resP_at_txString = "Zonally Averaged Zonal wind"
However, no text string appears. When this did not work, I
experimented with including more space at the top and the bottom,
using these commands :
   resP_at_gsnPanelTop = 0.05 ; add some space at
top
   resP_at_gsnPanelBottom = 0.05 ; add some space at
bottom

This did not appear to change anything. I am not sure how to get a
single title at the top of all the panels.

3). I succeeded in removing the numbers and ticks marks on the bottom
(x-axis) of each plot to save space between the plots, using the
commands :

   res_at_tmXBLabelsOn = False ; do not draw bottom
labels
   res_at_tmXBOn = False ; no bottom
tickmarks

However, I need to re-include the numbers and tick marks on the x-axis
rows at the very bottom of the panel (the numbers should give
latitude in degrees from pole to pole). I have not found any way of
doing this. Additionally, I also want x-axis annotation on the bottom
row to say "Latitude (degrees) ". Again, I am not sure how I can do
this.

4). On the y-axis I want the y-axis annotation saying "Pressure",
along with the tick marks and numbers on the left hand side only,
rather than on every plot, to save space between plots. Similarly on
the right hand side I want a single set of labels saying "Height (km)"
along with the numbers and tick marks, rather than having this on
every plot, so I can save space between the plots.

5. The plots are interpolated from hybrid levels to pressure/height
levels using NCL function "vinth2p". However much I lower the
uppermost interpolated level which is displayed on the plots using NCL
function "gsn_csm_pres_hgt", there always seems to be some of the
plots in the panel that have bits of white space left at the upper
boundary, even though this white space is not there on the same plots
when the highest level plotted is higher in altitude (although some of
the other plots then have different bits of white space left at the
top). I have experimented with adjusting the last parameter in vinth2p
to make it False (i.e. no extrapolation for missing pressure values)
and True (does have extrapolation for missing pressure values), but
this seems to make no difference to the resulting plots. Is there any
way I can get rid of these white spaces at the top of the plots ?.
These do not look good for publication quality plots.

Can anyone please make any suggestions so that I can get rid of the
above plotting problems ?.

I include my current NCL script below (a), as well as the original
image I am trying to make into a panel in (b) and my current panel
plot in (c).

Thank you,
Helen.

(a) Current script :

;***********************
; pantest2.ncl
;***********************
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/contributed.ncl"

begin

; Keep all files open when have a lot of files :
   setfileoption("nc","SuppressClose",False)

   diri = "./"
   fili = systemfunc("cd "+diri+" ; ls zeusrand09125*.cam2.h0*nc")
   print(fili)
   nfili = dimsizes(fili)

lev_p = (/ 91500., 90000., 87500., 80000., 67500., 50000., 30000.,
20000., 10000., 5000., 3000., 1500., 750., 390., 200., 100., 50.,25.,
14., 7., 3.5, 1.9, 0.95, 0.4, 0.1, 0.03 /)

; ***********************************************
; Read in multiple files, interpolate, and write to temporary output
files
; **********************************************
   do nf = 0, nfili-1

   fi = addfile (diri+fili(nf), "r")

   diro = "./"
   filo = "uthelen"+nf+".nc"
   print(filo)
   system ("/bin/rm -f "+diro+filo) ; remove any pre-exist file
   fo = addfile (diro+filo, "c")

      hyam = fi->hyam ; read hybrid info
      hybm = fi->hybm
      hyai = fi->hyai ; read hybrid info
      hybi = fi->hybi
      PS = fi->PS
      P0mb = 0.01*fi->P0
      U = fi->U
      lat = fi->lat

   lev_p!0 = "lev_p" ; variable and dimension name
the same
   lev_p&lev_p = lev_p ; create coordinate variable
   lev_p_at_long_name = "pressure" ; attach some attributes
   lev_p_at_units = "hPa"
   lev_p_at_positive = "down"

; Up = vinth2p (U, hyam, hybm, lev_p ,PS, 1, P0mb, 2, False) ;
False = dont extrapolate pressures
      Up = vinth2p (U, hyam, hybm, lev_p ,PS, 1, P0mb, 2,
True) ; True = extrapolate pressures
      copy_VarAtts(U, Up)
      fo->U = Up ; write to netCDF file

      end do
; **************************
; calculate zonal average of zonal wind versus time for multiple
interpolated files
; *************************

  wks = gsn_open_wks ("pdf", "paninterp4.164to175" ) ;
open workstation

   plot = new(12,graphic)

   gsn_define_colormap(wks,"rainbow") ; choose colormap

   do nf2 = 0, nfili-1

   diri = "./"
; fili2 = systemfunc("cd "+diri+" ; ls uthelen*nc")
   fili2 = addfile (diri+"uthelen"+nf2+".nc","r")

   print(fili2)

; U2= addfiles_GetVar(f2,fili2,"U")

    U2 = fili2->U
   printVarSummary( U2 ) ; (time, lev_p, lat,lon)

   dimt2 = dimsizes( U2 )
   ntim2 = dimt2(0)
   klvl2 = dimt2(1)
   nlat2 = dimt2(2)
   mlon2 = dimt2(3)

; take zonal average

  uavg = dim_avg_Wrap(U2) ;
(time,lev_p,lat)
   printVarSummary( uavg )

;***********************
; Create Plot
;***********************

    nyear = 164+nf2
    nt2 = 0

   res = True

      res_at_gsnLeftString = ""
      res_at_gsnCenterString = "Year "+ nyear
      res_at_gsnRightString = ""

; res_at_tiXAxisString = "Time (years)"

   res_at_cnFillOn = True
   res_at_lbLabelAutoStride = True
   res_at_gsnMaximize = True ; if [ps, eps, pdf] make large
   res_at_gsnSpreadColors = True ; span color map
   res_at_lbLabelBarOn = False ; turn off individual colour bars
   res_at_tmXBLabelsOn = False ; do not draw bottom
labels
   res_at_tmXBOn = False ; no bottom tickmarks

   res_at_cnLevelSelectionMode = "ManualLevels" ; manually set the
contour levels with the following 3 resources
; res_at_cnMinLevelValF = -35. ; set the minimum
contour level
; res_at_cnMaxLevelValF = 75. ; set the maximum
contour level
; res_at_cnMinLevelValF = -30. ; set the minimum
contour level
; res_at_cnMaxLevelValF = 70. ; set the maximum
contour level
   res_at_cnMinLevelValF = -30. ; set the minimum
contour level
   res_at_cnMaxLevelValF = 65. ; set the maximum
contour level
   res_at_cnLevelSpacingF = 5. ; set the interval
between contours
; res_at_cnLevelSpacingF = 10. ; set the interval
between contours

; plot = gsn_csm_pres_hgt(wks, work, res ) ; (lev,time)
; plot(nf2) = gsn_csm_pres_hgt(wks, uavg(lev_p | 0:21, lat | :,
time | nt2), res ) ; (lev,lat)
      plot(nf2) = gsn_csm_pres_hgt(wks, uavg(lev_p | 0:20, lat | :,
time | nt2), res ) ; (lev,lat)
; plot(1) = gsn_csm_pres_hgt(wks, uavg(lev_p | :, lat | :, time |
nt2), res ) ; (lev,lat)

    end do

      res_at_trYReverse = True

   resP = True ; modify the panel
plot
   resP_at_gsnPanelTop = 0.05 ; add some space at
top
   resP_at_gsnPanelBottom = 0.05 ; add some space at
bottom
   resP_at_txString = "Zonally Averaged Zonal wind"
   resP_at_gsnPanelLabelBar = True ; add common colorbar
   resP_at_lbLabelFontHeightF = 0.007 ; make labels smaller

; gsn_panel(wks,plot,(/6,2/),False)
    gsn_panel(wks,plot,(/4,3/),False)

end

(b) Original plot style :

(c) Panel plot :

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

zeus2.jpg panel2.jpg
Received on Mon Apr 20 2009 - 02:52:21 MDT

This archive was generated by hypermail 2.2.0 : Tue Apr 21 2009 - 11:04:41 MDT