[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


Mary,
This works perfectly.
Thank you,
Matt


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

Matt,

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))])
print(tmXBLabels)

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.

--Mary


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:
Hi,

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:

https://www.ncl.ucar.edu/Applications/Images/calipso_2_2_lg.png

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,
Matt






_______________________________________________
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/20180906/469ded66/attachment-0001.html>


More information about the pyngl-talk mailing list