[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.
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
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"]
Meanwhile, I've filed a ticket on this (PYNGL-114), because it shouldn't be this hard.
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.
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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pyngl-talk