Re: help with panel plot: time labels and hovmollers

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 10 2012 - 18:31:34 MDT

Getting this to work right usually requires some iteration. One approach is to divide the overall plot into 2 panels vertically using gsnPanelLeft and gsnPanelRight. You need to set these values to confine the three vertical plots to the space you want them to occupy without getting so narrow that you limit the overall length because the aspect ratio is preserved. You can overlap the space for the left and right sides to eliminate white space. I am attaching a revised version of the earlier script that does what you want. You may have to play with the numbers a bit for your situation. Oh and I just noticed that you will need to have different figure strings for each of the (sub) panels.
 -dave

On Aug 10, 2012, at 5:07 PM, Erik N wrote:

> Thank you, David. Your example is great.
> It helped me clean my code. Attached it my resulting plot. What command could I use to compress the y-axis for the 3 plots on the right?
> If I use the command, res@tmYLLabelsOn = False, ( or res2@tmYLLabelsOn = False in the code below), the time-axis label disappears, but there is a lot of white space.
> -Erik
>
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
>
> f1 = "1x1_grid_MERRA_daily_snapshot_00.nc"
> f2 = "1x1_grid_Experiment_27_daily_diagnostics.nc"
> f3 = "1x1_grid_RM3_daily_diagnostics.nc"
>
> a = addfile(f1+".nc","r")
> b = addfile(f2+".nc","r")
> c = addfile(f3+".nc","r")
> ; time
> timeUnits = a->time@units
> print(timeUnits)
> startDate = cd_inv_calendar( 2006, 09, 02, 00, 0, 0, timeUnits, 0 )
> endDate = cd_inv_calendar( 2006, 09, 13, 00, 0, 0, timeUnits, 0 )
> ; get data
> merrav = short2flt( a->V({startDate:endDate},{700},{5:20},{-20:10}) )
> wrfv = short2flt( b->V({startDate:endDate},{700},{5:20},{-20:10}) )
> rm3v = short2flt( c->V({startDate:endDate},{5:20},{-20:10}) )
> merraVort = short2flt( a->dVoverdX({startDate:endDate},{700},{5:20},{-20:10}) )
> wrfVort = short2flt( b->dVoverdX({startDate:endDate},{700},{5:20},{-20:10}) )
> rm3Vort = short2flt( c->dVoverdX({startDate:endDate},{5:20},{-20:10}) )
>
> ; For plotting purposes
> merraVort = merraVort*10
> wrfVort = wrfVort*10
> rm3Vort = rm3Vort*10
>
> ; Make hovmoller data
> merraVhov = dim_avg_n_Wrap( merrav, 1 )
> wrfVhov = dim_avg_n_Wrap( wrfv, 1 )
> rm3Vhov = dim_avg_n_Wrap( rm3v, 1 )
> merraVorthov = dim_avg_n_Wrap( merraVort, 1 )
> wrfVorthov = dim_avg_n_Wrap( wrfVort, 1 )
> rm3Vorthov = dim_avg_n_Wrap( rm3Vort, 1 )
>
> ; time, yet again
> timeUnits = "days since 1800-01-01 00:00:00"
> merraVhov&time = ut_convert( merraVhov&time, timeUnits )
> wrfVhov&time = ut_convert( wrfVhov&time, timeUnits )
> rm3Vhov&time = ut_convert( rm3Vhov&time, timeUnits )
> merraVorthov&time = ut_convert( merraVorthov&time, timeUnits )
> wrfVorthov&time = ut_convert( wrfVorthov&time, timeUnits )
> rm3Vorthov&time = ut_convert( rm3Vorthov&time, timeUnits )
>
> ;**********************************
> ; Make Plot
> ;**********************************
> plotname = "hovmoller_panel_circ1"
> wks = gsn_open_wks("pdf",plotname)
> res = True
> res@gsnDraw = False ; don't draw
> res@gsnFrame = False ; don't advance frame
>
> ; Black and White Contour plot
> res@gsnContourZeroLineThicknessF = 5 ; thickness of zero contour (Default = 1)
> res@gsnContourNegLineDashPattern = 1 ; sets negative contours to dash pattern
> res@cnInfoLabelOn = False ; turn off cn info label
>
> ; Set special resources for the time axis
> resTick = True
> resTick@ttmFormat = "%d %c"
> resTick@ttmAxis = "YL"
> resTick@ttmMajorStride = 1
>
> ; Set resources necessary to customize Y axis labels (You don't need all)
> time_axis_labels( merraVhov&time, res, resTick )
> ; time_axis_labels( wrfVhov&time, res, resTick )
> ; time_axis_labels( rm3Vhov&time, res, resTick )
> ; time_axis_labels( merraVorthov&time, res, resTick )
> ; time_axis_labels( wrfVorthov&time, res, resTick )
> ; time_axis_labels( rm3Vorthov&time, res, resTick )
> res@tmYROn = False ; right tickmarks
>
> ; Set resources necessary to customize X axis labels
> res@gsnMajorLonSpacing = 5.
> res@tmXBTickSpacingF = 5.
> res@tmXTOn = False ; top tickmarks
>
> res@gsnLeftString = " "
> res@gsnCenterString = " "
> res@gsnRightString = " "
>
> ; -- Contour levels --
> res1 = res
> res1@cnLevelSelectionMode = "ManualLevels"
> ; set contour levels (wind -10 to 10 by 2)
> res1@cnMinLevelValF = -10
> res1@cnMaxLevelValF = 10
> res1@cnLevelSpacingF = 2
>
> res2 = res
> res2@cnLevelSelectionMode = "ManualLevels"
> ; set contour levels (vort -20 to 20 by 4)
> res2@cnMinLevelValF = -16
> res2@cnMaxLevelValF = 16
> res2@cnLevelSpacingF = 4
> res2@tmYLLabelsOn = False
> ;-----
> plot = new(6,graphic)
>
> plot(0) = gsn_csm_hov(wks,merraVhov,res1)
> plot(1) = gsn_csm_hov(wks,merraVorthov,res2)
> plot(2) = gsn_csm_hov(wks,wrfVhov,res1)
> plot(3) = gsn_csm_hov(wks,wrfVorthov,res2)
> plot(4) = gsn_csm_hov(wks,rm3Vhov,res1)
> plot(5) = gsn_csm_hov(wks,rm3Vorthov,res2)
>
> ;************************************************
> ; create panel
> ;************************************************
> resP = True
> resP@gsnPanelFigureStrings= (/"a)","b)","c)","d)","e)","f)"/) ; add strings to panel
> resP@gsnPanelFigureStringsFontHeightF = 0.015
> resP@amJust = "TopRight"
> ;resP@gsnMaximize = True
> gsn_panel(wks,plot,(/3,2/),resP) ; now draw as one plot (row,column)
> frame(wks)
>
>
> <hovmoller_panel_circ1.pdf>_______________________________________________
> 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 Fri Aug 10 18:31:59 2012

This archive was generated by hypermail 2.1.8 : Wed Aug 15 2012 - 08:12:08 MDT