[ncl-talk] panel plot preceded by individual figures

Alexander Schaefer alexander.schaefer at mines.sdsmt.edu
Sun Jun 7 13:53:54 MDT 2015


Mira,

You set res and have the gsnDraw and gsnFrame set right but you never use
it.

Easiest fix would be to set "vcres = res" instead of "vcres = True".

This should be the only thing you need to fix it.

-Alex

On Sunday, June 7, 2015, <mberdahl at envsci.rutgers.edu> wrote:

> Hi all,
> I am trying to make a simple panel plot, but instead of just getting a
> single panel plot, I get every image on a separate page of the ps file,
> followed finally by the panel plot at the end. The code here shows that I
> do a seasonal average of winds, and want to plot all four seasons as
> panels.  However the pdf file this script outputs is 5 pages long - first
> four pages are a plot for each season, followed by the panel plot at the
> end. Is there something in my script that is causing each figure to print
> individually before finally printing in the panel?
> Thanks for any help!
> Mira
>
> ********************************************************************
>
>
>
> 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/csm/shea_util.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
> a = addfile("uwnd.mon.mean.nc","r")
> print(a)
> b = addfile("vwnd.mon.mean.nc","r")
>
> ;************************************************
> ; read in zonal [u] and meridional [v] winds (July)
> ;************************************************
>
> u = a->uwnd(0:803,{45:90},{270:357.5})
> v = b->vwnd(0:803,{45:90},{270:357.5}) ; Get u, v, time (1948:2014),level
> (1000hpa),latitude(-90:90) and longitude(0:360) data.
>
> printVarSummary(u)
> printVarSummary(v)
>
> ; to take the average over the first dimensions (time)
> ;uAvgTime = dim_avg_n_Wrap(u,0)
> ;vAvgTime = dim_avg_n_Wrap(v,0)
>
> ;printVarSummary(vAvgTime)
> ;printVarSummary(uAvgTime)
>
> ; calculate speed from u and v components
> ;speed = sqrt(uAvgTime^2+vAvgTime^2)
>
> ; Calculate the seasonal averages.
> uDJF = month_to_season(u, "DJF")
> vDJF = month_to_season(v, "DJF")
> uMAM = month_to_season(u, "MAM")
> vMAM = month_to_season(v, "MAM")
> uJJA = month_to_season(u, "JJA")
> vJJA = month_to_season(v, "JJA")
> uSON = month_to_season(u, "SON")
> vSON = month_to_season(v, "SON")
>
> ;printVarSummary(uDJF)
> ;printVarSummary(vDJF)
>
>
>
> uAvgTime_DJF = dim_avg_n_Wrap(uDJF,0)
> vAvgTime_DJF = dim_avg_n_Wrap(vDJF,0)
>
> uAvgTime_MAM = dim_avg_n_Wrap(uMAM,0)
> vAvgTime_MAM = dim_avg_n_Wrap(vMAM,0)
>
> uAvgTime_JJA = dim_avg_n_Wrap(uJJA,0)
> vAvgTime_JJA = dim_avg_n_Wrap(vJJA,0)
>
> uAvgTime_SON = dim_avg_n_Wrap(uSON,0)
> vAvgTime_SON = dim_avg_n_Wrap(vSON,0)
>
>
> ;************************************************
> ; create plot
> ;************************************************
> wks = gsn_open_wks("ps","Panel_seasonalMean")           ; open a ps file
> plot = new(4,graphic)                           ; create a plot array
>
> res                     = True
> res at gsnDraw             = False                 ; dont draw
> res at gsnFrame            = False                 ; dont advance frame
> res at cnInfoLabelOn       = False                 ; trn off cn info label
>
> vcres = True                                    ; plot mods desired
> vcres at gsnAddCyclic = False                      ; has to do with wrapping
> the longitude at 0/360
> vcres at vcRefAnnoOrthogonalPosF = -1.0            ; move ref vector up
> vcres at vcRefMagnitudeF = 10.0                    ; define vector ref mag
> vcres at vcRefLengthF = 0.045                      ; define length of vec ref
> vcres at vcGlyphStyle = "CurlyVector"              ; turn on curly vectors
> vcres at vcMinDistanceF = 0.017
>
> ;************************************************
> ; Choose a subregion
> ;************************************************
> vcres at mpFillOn = False                          ; turn off gray fill
> vcres at mpOutlineBoundarySets = "National"        ; turn on country
> boundaries
> vcres at mpGeophysicalLineColor = "Navy"           ; color of cont. outlines
> vcres at mpGeophysicalLineThicknessF = 1.5         ; thickness of outlines
>
> vcres at mpMaxLatF = 90                            ;maximum latitude
> vcres at mpMinLatF = 45                            ;minimum latitude
> vcres at mpMaxLonF = 357.5                         ;maximum longitude
> vcres at mpMinLonF = 270                           ;minimum longitude
>
> plot(0) = gsn_csm_vector_map_ce(wks,uAvgTime_DJF,vAvgTime_DJF,vcres)
> plot(1) = gsn_csm_vector_map_ce(wks,uAvgTime_MAM,vAvgTime_MAM,vcres)
> plot(2) = gsn_csm_vector_map_ce(wks,uAvgTime_JJA,vAvgTime_JJA,vcres)
> plot(3) = gsn_csm_vector_map_ce(wks,uAvgTime_SON,vAvgTime_SON,vcres)
>
>
> ;************************************************
> ; create panel
> ;************************************************
> resP = True                                     ; modify the panel plot
> resP at txString = "Seasonal Mean Winds"
> gsn_panel(wks,plot,(/4,1/),resP)                ; now draw as one plot
>
>
>
> end
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <javascript:;>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150607/1567cc56/attachment.html 


More information about the ncl-talk mailing list