[pyngl-talk] double x-axis labels in Ngl.xy

Fearon, Dr. Matthew, Contractor, Code 7533 matthew.fearon.ctr at nrlmry.navy.mil
Thu Sep 6 11:58:14 MDT 2018

This works perfectly.
Thank you,

From: Mary Haley [mailto:haley at ucar.edu]
Sent: Thursday, September 6, 2018 7:39 AM
To: Fearon, Dr. Matthew, Contractor, Code 7533
Cc: pyngl-talk at ucar.edu
Subject: Re: [pyngl-talk] double x-axis labels in Ngl.xy


You still need to use the tmXBMode / tmXBLabels / tmXBFormat resources, and then you can use the string formatting capability in Python.

lats = [-30,   -20.41  , -9.21,   2.589, 14.316]
lons = [125.0, 143.123, 158.91, 173.689, 188.71]
tmXBLabels = (["{:0.2f}~C~{:0.2f}".format(lats[i],lons[i]) for i in range(len(lats))])

This should produce:

['-30.00~C~125.00', '-20.41~C~143.12', '-9.21~C~158.91', '2.59~C~173.69', '14.32~C~188.71']

which you can use as your argument to xmXBLabels.


On Wed, Sep 5, 2018 at 2:46 PM, Fearon, Dr. Matthew, Contractor, Code 7533 via pyngl-talk <pyngl-talk at ucar.edu<mailto:pyngl-talk at ucar.edu>> wrote:

I am trying to produce lat/long labels along the x-axis in an XY plot in a manner consistent with the third/lower panel in the following plot:


In NCL, I was able to embed a carriage return in a string format sequence as follows:

tmXBLabels  = sprintf("%.1f",xlabel_lat)+"~C~"+sprintf("%.1f",xlabel_lon)

I’m not sure if there is an equivalent in PyNGL or Python for adding labels this way in Ngl.xy? Any suggestions would be greatly appreciated.

Thank you,

pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:

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

More information about the pyngl-talk mailing list