[pyngl-talk] double x-axis labels in Ngl.xy
Mary Haley
haley at ucar.edu
Thu Sep 6 08:39:24 MDT 2018
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> 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/63778ad0/attachment.html>
More information about the pyngl-talk
mailing list