Re: Trying to produce a Panel Plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue, 21 Apr 2009 10:27:00 -0600 (MDT)

Helen,

You are setting "False" in the last argument of gsn_panel,
so none of your panel resources are taking effect:

      gsn_panel(wks,plot,(/4,3/),False)

Change to:

      gsn_panel(wks,plot,(/4,3/),resP)

You should be able to remove the gsnPanelTop/gsnPanelBottom resources,
as internally, the code should calculate these as needed for the title.

--Mary

On Tue, 21 Apr 2009 asphilli_at_ucar.edu wrote:

> Hi Helen,
> Can you try setting resP_at_gsnPanelTop = 0.8, resP_at_gsnPanelBottom = 0.2, and
> sending us a .gif/.jpg of the result? I would be curious to see the
> resulting plot.
> Adam
>
>
>> Dear Mary,
>>
>> The lines you suggested did succeed in removing the contour line labels
> and the information label bars, which helps. However, I am still unable
> to get a main title for the panel plot.
>>
>> I am also still struggling to find a way to get the tick annotation to
> reappear on the bottom plots only in the panel. It seems that once you
> eliminate them on individual plots they do not want to come back. I have
> also attempted to put on an x-axis title, on the bottom plots only, but
> this also does not want to appear. I believe I am doing what is shown in
> the examples.
>>
>> Note that I had originally tried using the four resP lines you
>> suggested, i.e.
>>> resP = True ; modify the panel
>>> plot
>>> resP_at_txString = "Zonally Averaged Zonal wind"
>>> resP_at_gsnPanelLabelBar = True ; add common colorbar
> resP_at_lbLabelFontHeightF = 0.007 ; make labels smaller
>>
>> and had only tried adding some more space at the top with
>> resP_at_gsnPanelTop because it did not work. It still does not work if I
> remove this (and I have, amongst other things, tried putting it back
> again).
>>
>> I enclose my current script and panel plot. I am not getting any error
> messages or warnings when I run this script.
>>
>> Thanks,
>> Helen.
>>
>> (a) Current script :
>>
>> ;***********************
>> ; pantest3.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_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_cnLineLabelsOn = False ; Turn off contour line labels
>> res_at_cnInfoLabelOn = False ; Turn off informational label
>> if (nf2 .le. 8) then
>> res_at_tmXBLabelsOn = False ; do not draw bottom
>> labels
>> res_at_tmXBOn = False ; no bottom tickmarks
> res_at_lbLabelBarOn = False ; turn off individual colour bars
>> end if
>>
>> res_at_trYReverse = True
>>
>> res_at_cnLevelSelectionMode = "ManualLevels" ; manually set the
>> contour levels with the following 3 resources
>> 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
>>
>> if (nf2 .ge. 9) then
>> res_at_tmXBOn = True ; draw bottom tickmarks
>> res_at_tmXBLabelsOn = True ; draw bottom labels
>> res_at_tiXAxisString = "Latitude (degrees)"
>> end if
>> plot(nf2) = gsn_csm_pres_hgt(wks, uavg(lev_p | 0:20, lat | :,
>> time | nt2), res ) ; (lev,lat)
>>
>> end do
>>
>> resP = True ; modify the panel
>> plot
>> resP_at_gsnPanelTop = 0.95 ; 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,(/4,3/),False)
>>
>> end
>>
>>
>> (b) Current panel plot :
>>
>>
>>
>> On Apr 20, 2009, at 8:51 AM, Mary Haley wrote:
>>
>>> Helen,
>>> This may be a bug, and I'll take a look.
>>> Meanwhile, try setting these additional resources:
>>> res_at_cnLineLabelsOn = False ; Turn off contour line labels
>>> res_at_cnInfoLabelOn = False ; Turn off informational label
>>> For the main title, setting:
>>> resP_at_txString = "...."
>>> should work for getting you a main title. However, setting:
>>> resP_at_gsnPanelTop = 0.05 ; add some space
>>> at top
>>> will not work, because 0.05 is at the bottom of the screen. I think you
> meant to try 0.95.
>>> You shouldn't need to set gsnPanelTop, though, so try just these
> settings to see if the title shows up:
>>> resP = True ; modify the panel
>>> plot
>>> 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,(/4,3/),False)
>>> If the title still doesn't show up, then please send me the resultant
> image, and any errors/warnings that may be showing up when you run your
> script.
>>> --Mary
>>> On Mon, 20 Apr 2009, Helen Parish wrote:
>>>> 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.
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 21 2009 - 10:27:00 MDT

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