[ncl-talk] Scaling unequally sized plots to the same height in panelplot

Adam Phillips asphilli at ucar.edu
Mon Apr 19 16:21:51 MDT 2021


Hi Tabish,
There are two ways to go about this that I have used.
1 - Draw each row separately with 3 calls to gsn_panel, and create the
labelbar through panel resources.
2 - Draw all 12 plots as you are doing, but use gsn_labelbar_ndc to draw
the labelbars separately.

I would highly recommend going with method #1.
An example of doing this:

panres = True
panres at gsnDraw = False
panres at gsnFrame = False
panres at gsnMaximize = False   ; this has to be False for this method to work
panres at gsnPanelLabelBar = True
panres at lbOrientation = "vertical"
... (set other labelbar resources here in the panel resource list)
panres at gsnPanelTop = .99
panres at gsnPanelBottom = .66
gsn_panel(wks,(/plot1,plot2,plot3,plot4/),(/1,4/),panres)
panres at gsnPanelTop = .66
panres at gsnPanelBottom = .33
gsn_panel(wks,(/plot5,plot6,plot7,plot8/),(/1,4/),panres)
panres at gsnPanelTop = .33
panres at gsnPanelBottom = .0
gsn_panel(wks,(/plot9,plot10,plot11,plot12/),(/1,4/),panres)
maximize_output(wks,False)   ; alternatively if you are happy with the
default size of the output, do not call maximize_output, set panres at gsnDraw
= True, and call frame(wks) on this line

You might have to go through some trial and error to get the output to what
you would like, but the above coding is a good place to start.
Good luck,
Adam

On Mon, Apr 19, 2021 at 12:27 PM Tabish Ansari via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi
>
> I'm trying to create a 3x4 panelplot. Each plot is a contour map generated
> from WRF model data. Since each row represents a similar quantity, I'm
> using a common labelbar for each row, which means I have a total of 3 label
> bars for this panelplot which are made visible for the 4th, 8th and 12th
> plots and turned off for all other plots. However, since the rightmost
> plots include the labelbars, NCL detects their overall size differently
> which leads to different sizing of the maps in the panel.
>
> Please see the attached plot.
>
> Here's the snippet of the graphics part of the code:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;PLOTTING
> OPTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>   type = "pdf"
>   wks = gsn_open_wks(type,"NOCOVOC_D02_sectoralemissions-panel")         ;
> Create a plot workstation
>   gsn_define_colormap(wks,"BlAqGrYeOrReVi200")
>   ;gsn_define_colormap(wks,"WhiteYellowOrangeRed")
>   ;gsn_define_colormap(wks,"hotres")
>   ;gsn_define_colormap(wks,"MPL_Reds")
> ; Set some basic resources
>   res = True
>
>   pltres = True
>   mpres = True
>   res at cnFillOn          = True               ; Create a color fill plot
>   pltres at PanelPlot = True
>   res at NoHeaderFooter           = True            ; Switch headers and
> footers off
>   mpres at mpOutlineOn = True  ; Turn on map outlines
>   mpres at mpFillOn    = False  ; Turn off map fill
>
>   res at cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour
> levels
>
>   COlevels =
> (/10,25,50,75,100,200,400,600,800,1000,1500,2000,3000,4000,5000/) ; set
> levels for CO
>   NOlevels = (/5,10,15,20,25,30,40,50,75,100,125,150,175,200,250/) ; set
> levels for NO
>   VOClevels = (/5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80/) ; set
> levels for NMVOCs
>   SO2levels = (/5,10,15,20,25,50,75,100,150,200,250,300/) ; set levels for
> SO2
>   NH3levels = (/5,10,15,20,25,30,35,40,45,50,60,70,80,90,100/) ; set
> levels for NH3
>   PMlevels =  (/10,25,50,100,150,200,250,500,1000,1500,2000,2500,3000/) ;
> set levels for Total Aerosol
>
>
>   res at lbLabelBarOn         = False        ; turn off labelbar, but still
> customize
>   res at lbOrientation        = "Vertical"   ; it so we can recreate it later
>   res at lbTitleAngleF        = 90.          ; title angle
>   res at lbTitlePosition      = "Right"      ; title location
>   res at lbTitleDirection     = "Across"     ; letter angle
>   res at lbLabelFontHeightF   = 0.025
>   res at pmLabelBarOrthogonalPosF = -1.05
>   res at pmLabelBarParallelPosF = 1.2
>
> ;---Resources for 1st row of plots
>   res1                = res
>   res1 at cnLevels       = NOlevels
>   res1 at lbTitleString  = "NO"
>
> ;---Resources for 2nd row of plots
>   res2                = res
>   res2 at cnLevels       = COlevels
>   res2 at lbTitleString  = "CO"
>
> ;---Resources for 3rd row of plots
>   res3                = res
>   res3 at cnLevels       = VOClevels
>   res3 at lbTitleString  = "NMVOC"
>
> ;---Contour resources for each set of contour plots
>   res11               = res1
>   res12               = res1
>   res13               = res1
>   res14               = res1
>
>   res21               = res2
>   res22               = res2
>   res23               = res2
>   res24               = res2
>
>   res31               = res3
>   res32               = res3
>   res33               = res3
>   res34               = res3
>
> ;---Rightmost plots
>   res14 at lbLabelBarOn = True
>   res24 at lbLabelBarOn = True
>   res34 at lbLabelBarOn = True
>
>   contour_NO_ind  = wrf_contour(c2,wks,NO_ind,res11)
>   contour_NO_pow  = wrf_contour(c2,wks,NO_pow,res12)
>   contour_NO_tran = wrf_contour(c2,wks,NO_tran,res13)
>   contour_NO_res  = wrf_contour(c2,wks,NO_res,res14)
>
>
>   contour_CO_ind  = wrf_contour(c2,wks,CO_ind,res21)
>   contour_CO_pow  = wrf_contour(c2,wks,CO_pow,res22)
>   contour_CO_tran = wrf_contour(c2,wks,CO_tran,res23)
>   contour_CO_res  = wrf_contour(c2,wks,CO_res,res24)
>
>
>   contour_VOC_ind  = wrf_contour(c2,wks,VOC_ind,res31)
>   contour_VOC_pow  = wrf_contour(c2,wks,VOC_pow,res32)
>   contour_VOC_tran = wrf_contour(c2,wks,VOC_tran,res33)
>   contour_VOC_res  = wrf_contour(c2,wks,VOC_res,res34)
>   mpres at mpOutlineBoundarySets       = "AllBoundaries"   ; turn on country
> boundaries
>   mpres at mpGeophysicalLineColor      = "Black"       ; color of cont.
> outlines
>   mpres at mpNationalLineColor         = "Black"       ; color of cont.
> outlines
>   mpres at mpProvincialLineColor      = "Black"       ; color of cont.
> outlines
>   mpres at mpGeophysicalLineThicknessF = 1.5          ; thickness of outlines
>   mpres at mpNationalLineThicknessF = 1.5          ; thickness of outlines
>   mpres at mpProvincialLineThicknessF = 1.5          ; thickness of outlines
>   mpres at mpDataBaseVersion = "MediumRes"            ; choose higher
> resolution
>   mpres at mpDataSetName = "Earth..4"                 ; choose most recent
> boundaries
>
>
> ; MAKE PLOTS
> ;pltres at FramePlot = False  ; do not frame plot - will do this manually
> later
> mpres at tmXTOn = True
> mpres at tmYROn = True
>   mpres at tmXBMajorOutwardLengthF = 0.0               ; draw tickmarks
> inward
>   mpres at tmXBMinorOutwardLengthF = 0.0               ; draw minor ticks
> inward
>   mpres at tmYLMajorOutwardLengthF = 0.0               ; draw tickmarks
> inward
>   mpres at tmYLMinorOutwardLengthF = 0.0               ; draw minor ticks
> inward
>   mpres at tmXTMajorOutwardLengthF = 0.0               ; draw tickmarks
> inward
>   mpres at tmXTMinorOutwardLengthF = 0.0               ; draw minor ticks
> inward
>   mpres at tmYRMajorOutwardLengthF = 0.0               ; draw tickmarks
> inward
>   mpres at tmYRMinorOutwardLengthF = 0.0               ; draw minor ticks
> inward
>
>   mpres at tmXBLabelFontHeightF = 0.017
>
>  plot1 = wrf_map_overlays(c2,wks,(/contour_NO_ind/),pltres,mpres)
>  plot2 = wrf_map_overlays(c2,wks,(/contour_NO_pow/),pltres,mpres)
>  plot3 = wrf_map_overlays(c2,wks,(/contour_NO_tran/),pltres,mpres)
>  plot4 = wrf_map_overlays(c2,wks,(/contour_NO_res/),pltres,mpres)
>
>  plot5 = wrf_map_overlays(c2,wks,(/contour_CO_ind/),pltres,mpres)
>  plot6 = wrf_map_overlays(c2,wks,(/contour_CO_pow/),pltres,mpres)
>  plot7 = wrf_map_overlays(c2,wks,(/contour_CO_tran/),pltres,mpres)
>  plot8 = wrf_map_overlays(c2,wks,(/contour_CO_res/),pltres,mpres)
>
>  plot9 = wrf_map_overlays(c2,wks,(/contour_VOC_ind/),pltres,mpres)
>  plot10 = wrf_map_overlays(c2,wks,(/contour_VOC_pow/),pltres,mpres)
>  plot11 = wrf_map_overlays(c2,wks,(/contour_VOC_tran/),pltres,mpres)
>  plot12 = wrf_map_overlays(c2,wks,(/contour_VOC_res/),pltres,mpres)
>
> ;---Retrieve the height used for the first plot and apply to subsequent
> plots
>   getvalues plot1
>     "vpHeightF" : vph
>   end getvalues
> setvalues
> (/plot1,plot2,plot3,plot4,plot5,plot6,plot7,plot8,plot9,plot10,plot11,plot12/)
>   "vpHeightF" : vph
> end setvalues
>
>   pltres at PanelPlot = True
>
>   ; Panel the WRF plots.
>     pnlres                            = True
>     pnlres at gsnPanelYWhiteSpacePercent = 5       ; Add white space b/w
> plots.
>   pnlres at gsnMaximize = True
>
> gsn_panel(wks,(/plot1,plot2,plot3,plot4,plot5,plot6,plot7,plot8,plot9,plot10,plot11,plot12/),(/3,4/),pnlres)
>
>   frame(wks)
>
> I'll be extremely grateful if you could please point me to the right
> direction on how to make all plots of the same height without leaving too
> much white space in between them.
>
> Cheers,
>
> Tabish
>
> *----------------------------------------------------------Dr Tabish U
> Ansari <https://www.rug.nl/staff/t.u.ansari/>*
> *Assistant Professor - Earth & Energy*
>
> *University of Groningen - Campus Fryslân <https://www.rug.nl/cf/?lang=en>*
>
> *Leeuwarden, the Netherlands*
> *ResearchGate <https://www.researchgate.net/profile/Tabish_Ansari> |
> Google Scholar
> <https://scholar.google.com/citations?user=E94r-mwAAAAJ&hl=en&oi=ao> |
> Twitter <https://twitter.com/tabishbiet> *
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk



-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210419/0571d007/attachment.html>


More information about the ncl-talk mailing list