[ncl-talk] BoxCenters in pyNGL

Clinton Rowe crowe1 at unl.edu
Fri Aug 17 15:10:01 MDT 2018


Hi Mary,

I thought you were off somewhere taking a well-deserved vacation after our meeting!

I was running version 1.5.0_beta20161122, so I did conda update –c conda-forge pyngl pynio and am now running version 1.5.0. I can recreate what you got for contour2.py.  Thanks!

Now, for the next mystery with my labels. As you may recall, I “translated” my original NCL script to pyNGL. When I did this, a strange thing happened to my labelbar when plotting landuse (and other categorical data). As you can see, my labels are nicely in the center of the boxes, as I desired (thanks to you), but the label values are not correct. The resources I set for each plot are the same, with the exception of NCL-to-pyNGL translation.

NCL snippet
   fres at cnFillOn             = True               ; color Fill
   fres at cnFillMode           = "RasterFill"       ; Raster Mode
   fres at cnLinesOn            =  False             ; Turn off contour lines
   fres at cnLevelSelectionMode = "ExplicitLevels" ; set explict contour levels
   fres at cnLevels             = ispan(2,nc,1)
   fres at lbLabelPosition      = "Center"           ; label position
   fres at lbLabelAlignment     = "BoxCenters"       ; label orientation
   fres at lbLabelStrings       = ispan(1,nc,1)
   fres at lbLabelFontHeightF   = 0.009
   fres at pmLabelBarHeightF    = 0.075
   fres at mpFillOn             = False
   fres at pmLabelBarOrthogonalPosF = -.035           ; move whole thing up

   plot = gsn_csm_contour_map(wks, fvar, fres) ; create plot

pyNGL snippet
    fres.cnFillOn             = True               # color Fill
    fres.cnFillMode           = "RasterFill"       # Raster Mode
    fres.cnFillPalette        = colmap
    fres.cnLinesOn            = False              # Turn off contour lines
    fres.cnLevelSelectionMode = "ExplicitLevels"   # set explict contour levels
    fres.cnLevels             = range(2,ncat+1)
    fres.cnLineLabelsOn       = False
    fres.lbOrientation        = "Horizontal"
    fres.lbLabelPosition      = "Center"
    fres.lbLabelAlignment     = "BoxCenters"       # label orientation
    fres.lbLabelStrings       = range(1,ncat+1)
    fres.lbLabelFontHeightF   = 0.009
    fres.lbTitlePosition      = "Bottom"
    fres.lbTitleFontHeightF   = 0.010

    fplot = Ngl.contour(wks, fvar, fres) # create plot

I’m at a loss to figure out what’s happening here.

Clint

========================================================
Clinton M. Rowe
Professor and Graduate Chair         phone:(402)472-1946
Earth & Atmospheric Sciences           fax:(402)472-4917
University of Nebraska- Lincoln           crowe1 at unl.edu<mailto:crowe1 at unl.edu>

From: Mary Haley <haley at ucar.edu>
Sent: Thursday, August 16, 2018 7:28 PM
To: Clinton Rowe <crowe1 at unl.edu>
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] BoxCenters in pyNGL

Hi Clint,

Sorry for taking so long to get back to this. I'm slowing climbing my way back to normalcy after a few weeks of constant meetings.

I'm wondering if this example has been fixed in the latest PyNGL, because it worked fine for me, although one label is missing because once you go to box centers, you have to provide an additional label. (You can add the extra label with lbLabelStrings.)

I installed PyNGL and PyNIO with:

conda create --name pyn_env --channel conda-forge pynio pyngl

and then ran your attached script, with the resultant attached image.

Do you know what version of PyNGL you're running? You can print "Ngl.__version__
" for this information.

--Mary

On Fri, Aug 3, 2018 at 10:43 AM, Clinton Rowe <crowe1 at unl.edu<mailto:crowe1 at unl.edu>> wrote:
Mary, Rick, et al.,

I transitioned a routine from NCL to pyNGL and the BoxCenters label resource is not working.  Labels are only drawn at alternate interior lines on the labelbar, rather than the box centers as desired.  As an example, I added one line to contour2.py to request labels at the center of the boxes.  I’ve attached the modified example and output png.

Thanks,
Clint

========================================================
Clinton M. Rowe
Professor and Graduate Chair         phone:(402)472-1946
Earth & Atmospheric Sciences           fax:(402)472-4917
University of Nebraska- Lincoln           crowe1 at unl.edu<mailto:crowe1 at unl.edu>

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk<https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=Cu5g146wZdoqVuKpTNsYHeFX_rg6kWhlkLF8Eft-wwo&r=ubRAum_abJ_VeyWwkZyVzQ&m=8cUMz0iNSykheFbeusuXgwm6yRiLJGxOl84WZqwmJNc&s=bnEJJeofaPnySgZWsqUV6F4_5KhWCcFLPajWl_fIn34&e=>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180817/f7d105a8/attachment.html>


More information about the ncl-talk mailing list