[pyngl-talk] labelbar strings with contour

Fearon, Dr. Matthew, Contractor, Code 7533 matthew.fearon.ctr at nrlmry.navy.mil
Tue May 15 17:06:58 MDT 2018


Thank you, Mary. I’ll give this a try. Appreciate your help.
Matt

From: Mary Haley [mailto:haley at ucar.edu]
Sent: Tuesday, May 15, 2018 2:34 PM
To: Fearon, Dr. Matthew, Contractor, Code 7533
Cc: pyngl-talk at ucar.edu
Subject: Re: [pyngl-talk] labelbar strings with contour

Hi Matt,

I'm so sorry I didn't see this question sooner.

I have to admit that this one stumped me. It is much easier to do this using the gsn_csm_contour_map function in NCL, because that function is reconstructing the labelbar from scratch, and it explicitly allows you to change this resource.

PyNGL, on the other hand, is using the default labelbar that's provided when you create a contour plot, and apparently this default doesn't like you trying to change the label strings.

I was able to get this to work by creating the plot, and then setting the label strings after the fact using set_values. Please see the attached example script. Hopefully you can run it as is, but here are the lines that are important:


# After plot is created, then we can change the labels (?!)
rlist  = Ngl.Resources()
rlist.lbLabelStrings = ["one","","three","four"]
Ngl.set_values(map.contour,rlist)

Ngl.draw(map)
Ngl.frame(wks)

Meanwhile, I've filed a ticket on this (PYNGL-114), because it shouldn't be this hard.

--Mary


On Wed, May 9, 2018 at 2:51 PM, Fearon, Dr. Matthew, Contractor, Code 7533 via pyngl-talk <pyngl-talk at ucar.edu<mailto:pyngl-talk at ucar.edu>> wrote:
Dear PyNGL Users:

Trying to contour with ExplicitLevels and alter labelbar strings. Here’s my resource settings below with the image attached (see label bar). I am not getting the labelbar strings I was hoping for (ie, levels). I have tried having the following variable “levels” be a list or numpy array. Results remain the same. Any thoughts would be much appreciated.

Thank you,
Matt


    sres.cnFillMode            = "RasterFill"
    sres.cnLevelSelectionMode  = "ExplicitLevels"
    levels                     = np.asarray([2,4,7.5,14,27,53,103,200,386,745,1439,2779,5365,10359,20000])
    sres.cnLevels              = levels

    sres.lbAutoManage          = False
    sres.lbLabelStride         = 2
    sres.pmLabelBarWidthF      = 0.018
    sres.lbLabelFontHeightF    = 0.009
    sres.pmLabelBarOrthogonalPosF = 0.002
    sres.lbLabelStrings        = levels

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180515/b8e14e4d/attachment-0001.html>


More information about the pyngl-talk mailing list