[ncl-talk] Custom panel plot

Mary Haley haley at ucar.edu
Tue May 22 15:32:24 MDT 2018


Hi James and Appo,

Both of you have created some nice scripts that would be useful for the
panel examples page. Would one or both of you be willing to contribute your
script (and data file so I can run it) so we can add it to our page?

We do ask for a clean script, which means one that has unsed commented code
removed, somewhat consistent indentation, no references to personal
directories, etc.  I'm happy to help clean it up as well, if there are
things that you need help improving.

If you are able to contribute the script and data, feel free to do this
offline if you don't want to share the data publicly. We don't make the
data file available, but I do like to have it so I can make sure the script
runs with the latest version of NCL and that we create a nice PNG image
from it.

One small tip that might help with the subtitles not quite lining up.  If
you use "degK" instead of just "K" for gsnRightString, then your titles
will line up better because both titles will now have a character ('p' in
the left title and 'g' in the right title) that goes below the text base
line. If you don't want to repeat this title for every single plot, then I
suggest setting this title just once at the top. See script panel_41.ncl
for an example on how to do this:

http://www.ncl.ucar.edu/Applications/panel.shtml#ex41

Regards,

--Mary


On Tue, May 22, 2018 at 3:11 AM, Appo derbetini <appopson4 at gmail.com> wrote:

> Hi James
> I am on the right now as you can see on the attached plot.
>
> I am also sending script i used.
>
> Thank you
>
>
>
>
>    fname = "tas_2006.nc"
>     f     = addfile(fname,"r")
>         t       = f->tas(:, {-15:15}, {5:35})
>
>     lon = t&lon
>     lat = t&lat
>
>
>
>    pltDir = "./"                ; where output will be written
>    pltName= "panel29"
>    pltType= "png"               ; ps, eps, png, pdf, x11 .....
>
> ;***********************************************************
> *****************
> ; Miscellaneous
> ;***********************************************************
> *****************
>   nrow = 3
>   ncol = 4
>
>
>
> ;***********************************************************
> *****************
> ; Graphic resources
> ;***********************************************************
> *****************
>   pltPath = pltDir+pltName
>   wks     = gsn_open_wks(pltType ,pltPath)
>
>   res                       = True     ; plot mods desired
>   res at gsnDraw               = False
>   res at gsnFrame              = False
>
>   res at cnFillOn              = True     ; turn on color fill
>   res at cnLinesOn             = False    ; turn of contour lines
>   res at cnLineLabelsOn        = False    ; turn of contour line labels
>   ;res at cnLevelSelectionMode  = "ManualLevels"    ; set manual contour
> levels
>
>   res at lbLabelBarOn          = False
>
>
>
>  res at mpProjection                = "CylindricalEquidistant"       ;
> projection
>  res at mpLimitMode                 = "Corners"        ; method to zoom
>  res at mpLeftCornerLatF            = min(lat)
>  res at mpLeftCornerLonF            = min(lon)
>  res at mpRightCornerLatF           = max(lat)
>  res at mpRightCornerLonF           = max(lon)
>  res at tfDoNDCOverlay              = True             ; do no
>  res at gsnAddCyclic                = False            ; regional data,
> don't add pt
>
>
>   res at tmYLLabelsOn          = False    ; turn off lat labels
>   res at tmXBLabelsOn          = False    ; turn off lon labels
>
>   res at mpDataBaseVersion     = "MediumRes"
>   res at mpFillOn              = True
>   res at mpOutlineOn           = True
>   ;res at mpFillColors          = (/-1,0,-1,-1/)       ; mask out all
> non-land areas
>   res at mpFillOn                    = False        ; turn off gray fill
>
>   res at mpFillDrawOrder       = "PostDraw"
>   res at mpProjection          = "CylindricalEquidistant"
>
>
>   ;Ressource column 1
>    res1 = True
>    res1 = res
>    res1 at cnFillPalette        = "WhiteYellowOrangeRed"
>    res1 at lbOrientation      = "Horizontal"        ; orientation
>    ;res1 at pmLabelBarWidthF   = 0.8
>    ;res1 at pmLabelBarHeightF  = 0.03
>
>    res1 at lbLabelBarOn       = False
>    res1 at lbBoxEndCapStyle      = "TriangleBothEnds"
>
>
>    ;Ressource columns 2 & 3
>      res2 = True
>      res2 = res
>      res2 at cnFillPalette        = "MPL_YlGn"
>      res2 at lbOrientation      = "Horizontal"        ; orientation
>      res2 at pmLabelBarWidthF   = 1.1
>      ;res2 at pmLabelBarOrthogonalPosF  = -0.02
>      res2 at pmLabelBarParallelPosF  = -0.02
>
>      res2 at lbBoxEndCapStyle      = "TriangleBothEnds"
>
>
>     ;Ressource column 4
>      res3 = True
>      res3 = res
>      res3 at cnFillPalette        = "MPL_RdPu"
>      res3 at lbOrientation      = "Horizontal"        ; orientation
>      ;res3 at pmLabelBarWidthF   = 0.8
>
>      res3 at lbBoxEndCapStyle      = "TriangleBothEnds"
>
>
> ;***********************************************************
> *****************
> ; Generate panel entries
> ;***********************************************************
> *****************
>                                ; only one time per file
>   plot = new(nrow*ncol , "graphic")
>
>   ;res at cnFillPalette        = "WhiteYellowOrangeRed"
>     ;res1 at tmYLLabelsOn          = True    ; turn off lat labels
>    plot(0) = gsn_csm_contour_map(wks, t(0, :, :), res1)
>
>      res2 at tmYLLabelsOn          = False    ; turn off lat labels
>    plot(1) = gsn_csm_contour_map(wks, t(1, :, :), res2)
>    plot(2) = gsn_csm_contour_map(wks, t(2, :, :), res2)
>    plot(3) = gsn_csm_contour_map(wks, t(3, :, :), res3)
>
>
>     ;res1 at tmYLLabelsOn          = True
>     plot(4) = gsn_csm_contour_map(wks, t(4, :, :), res1)
>     res2 at tmYLLabelsOn          = False    ; turn off lat labels
>     plot(5) = gsn_csm_contour_map(wks, t(5, :, :),  res2)
>     plot(6) = gsn_csm_contour_map(wks, t(6, :, :), res2)
>     plot(7) = gsn_csm_contour_map(wks, t(7, :, :),  res3)
>
>
>     res1 at lbLabelBarOn          = True
>     ;res2 at tmYLLabelsOn          = True
>     ;res1 at tmXBLabelsOn          = True    ; turn off lon labels
>     ;res2 at tmXBLabelsOn          = True    ; turn off lon labels
>
>     plot(8) = gsn_csm_contour_map(wks, t(8, :, :), res1)
>     res2 at tmYLLabelsOn          = False    ; turn off lat labels
>     plot(9) = gsn_csm_contour_map(wks, t(9, :, :),  res2)
>
>       res2 at lbLabelBarOn       = True
>     plot(10) = gsn_csm_contour_map(wks, t(10, :, :),res2)
>
>     res3 at lbLabelBarOn       = True
>    plot(11) = gsn_csm_contour_map(wks, t(11, :, :), res3)
>
>
>
>
>
> ;***********************************************************
> *****************
> ; Draw the panel and label bars
> ;***********************************************************
> *****************
>   resP = True
>   ;resP at gsnPanelMainString = "Land Only: Tmax: 2 Colorbars"
>   resP at gsnMaximize = True
>   resP at gsnFrame    = False
>  ;resP at gsnPanelRight  = 0.98
>   ;resP at gsnPanelBottom = 0.045
>
>    resP at gsnPanelFigureStrings= (/"1","1","1","1","2","2","2","2","3","3","3","3"/)
> ; add strings to panel
>     resP at amJust   = "BottomLeft"
>
>   gsn_panel(wks,plot,(/nrow,ncol/),resP)  ; plots
>
>
>
>   frame(wks)
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20180522/2fe7e191/attachment.html>


More information about the ncl-talk mailing list