<div dir="ltr"><div>See <a href="https://github.com/matplotlib/matplotlib/issues/367">https://github.com/matplotlib/matplotlib/issues/367</a> for discussion and examples of good and bad ways of doing this.<br></div>Ian<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 October 2017 at 13:32, Slavin, Jonathan <span dir="ltr"><<a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">I'm wondering if we could make this easier by modifying contour/contourf so that the ContourSet object created had a paths object attribute.  It doesn't seem like it'd be that hard.  Maybe some would object that it would slow down the creation of contour plots?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Jon</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 18, 2017 at 5:08 PM,  <span dir="ltr"><<a href="mailto:matplotlib-users-request@python.org" target="_blank">matplotlib-users-request@<wbr>python.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Date: Thu, 19 Oct 2017 02:29:11 +0530<br>
From: "ashwin .D" <<a href="mailto:winash12@gmail.com" target="_blank">winash12@gmail.com</a>><br>
To: <a href="mailto:matplotlib-users@python.org" target="_blank">matplotlib-users@python.org</a><br>
Subject: [Matplotlib-users] Obtaining the contour data in terms of<br>
        latitude and longitude<br>
Message-ID:<br>
        <<a href="mailto:CAH0LXy4O%2B%2BPS3morh4B1L-83TvDqRG64YMkDrDe3LKQewFUSiw@mail.gmail.com" target="_blank">CAH0LXy4O++PS3morh4B1L-83TvDq<wbr>RG64YMkDrDe3LKQewFUSiw@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<div><div class="h5"><br>
<br>
Hello,<br>
         I have data on a 2d lat lon grid(equal grid spacing) in terms of<br>
laitude and longitude and heights as enclosed in the image. I need the<br>
coordinates(in terms of latitude and longitude) of the contours( as shown<br>
in red in the image). From this answer -<br>
<a href="https://stackoverflow.com/questions/18304722/python-find-contour-lines-from-matplotlib-pyplot-contour/" rel="noreferrer" target="_blank">https://stackoverflow.com/ques<wbr>tions/18304722/python-find-<wbr>contour-lines-from-matplotlib-<wbr>pyplot-contour/</a><br>
will this give me what I am looking for or is there a scaling required to<br>
latitude and longitude that I need to include?<br>
<br>
Best regards,<br>
Ashwin.<br>
<br>
import numpy as np<br>
def get_contour_verts(cn):<br>
    contours = []<br>
    # for each contour line<br>
    for cc in cn.collections:<br>
        paths = []<br>
        # for each separate section of the contour line<br>
        for pp in cc.get_paths():<br>
            xy = []<br>
            # for each segment of that section<br>
            for vv in pp.iter_segments():<br>
                xy.append(vv[0])<br>
            paths.append(np.vstack(xy))<br>
        contours.append(paths)<br>
<br>
    return contours<br></div></div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.python.org/pipermail/matplotlib-users/attachments/20171019/c5cb0664/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.python.org/piperm<wbr>ail/matplotlib-users/attachmen<wbr>ts/20171019/c5cb0664/attachmen<wbr>t-0001.html</a>><br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: sfc_trough1.gif<br>
Type: image/gif<br>
Size: 13312 bytes<br>
Desc: not available<br>
URL: <<a href="http://mail.python.org/pipermail/matplotlib-users/attachments/20171019/c5cb0664/attachment-0001.gif" rel="noreferrer" target="_blank">http://mail.python.org/piperm<wbr>ail/matplotlib-users/attachmen<wbr>ts/20171019/c5cb0664/attachmen<wbr>t-0001.gif</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 18 Oct 2017 17:08:16 -0400<br>
From: Benjamin Root <<a href="mailto:ben.v.root@gmail.com" target="_blank">ben.v.root@gmail.com</a>><br>
To: "ashwin .D" <<a href="mailto:winash12@gmail.com" target="_blank">winash12@gmail.com</a>><br>
Cc: Matplotlib-users <<a href="mailto:matplotlib-users@python.org" target="_blank">matplotlib-users@python.org</a>><br>
Subject: Re: [Matplotlib-users] Obtaining the contour data in terms of<br>
        latitude and longitude<br>
Message-ID:<br>
        <CANNq6FnAWDDv1vahui+WZY=<a href="mailto:JYwjEcQpiHDQUPxDKhbk-fEb6tQ@mail.gmail.com" target="_blank">JYwjE<wbr>cQpiHDQUPxDKhbk-fEb6tQ@mail.gm<wbr>ail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<div><div class="h5"><br>
<br>
If you passed the coordinate arrays in with the call to contourf(), then<br>
you will get what you expect.<br>
<br>
I should note that you should watch out for path simplification (you'll<br>
want to turn it off). I also recommend using contourf() over contour()<br>
because it handles the edges of the domain better and NaNs.<br>
<br>
Cheers!<br>
Ben Root<br>
<br>
<br>
On Wed, Oct 18, 2017 at 4:59 PM, ashwin .D <<a href="mailto:winash12@gmail.com" target="_blank">winash12@gmail.com</a>> wrote:<br>
<br>
> Hello,<br>
>          I have data on a 2d lat lon grid(equal grid spacing) in terms of<br>
> laitude and longitude and heights as enclosed in the image. I need the<br>
> coordinates(in terms of latitude and longitude) of the contours( as shown<br>
> in red in the image). From this answer - <a href="https://stackoverflow.com/" rel="noreferrer" target="_blank">https://stackoverflow.com/</a><br>
> questions/18304722/python-find<wbr>-contour-lines-from-<br>
> matplotlib-pyplot-contour/ will this give me what I am looking for or is<br>
> there a scaling required to latitude and longitude that I need to include?<br>
><br>
> Best regards,<br>
> Ashwin.<br>
><br>
> import numpy as np<br>
> def get_contour_verts(cn):<br>
>     contours = []<br>
>     # for each contour line<br>
>     for cc in cn.collections:<br>
>         paths = []<br>
>         # for each separate section of the contour line<br>
>         for pp in cc.get_paths():<br>
>             xy = []<br>
>             # for each segment of that section<br>
>             for vv in pp.iter_segments():<br>
>                 xy.append(vv[0])<br>
>             paths.append(np.vstack(xy))<br>
>         contours.append(paths)<br>
><br>
>     return contours<br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Matplotlib-users mailing list<br>
> <a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/matplotlib-users</a><br>
><br>
><br></div></div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.python.org/pipermail/matplotlib-users/attachments/20171018/b9f14b69/attachment.html" rel="noreferrer" target="_blank">http://mail.python.org/piperm<wbr>ail/matplotlib-users/attachmen<wbr>ts/20171018/b9f14b69/attachmen<wbr>t.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<span class=""><br>
<br>
______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/matplotlib-users</a><br>
<br>
<br></span>
------------------------------<br>
<br>
End of Matplotlib-users Digest, Vol 27, Issue 24<br>
******************************<wbr>******************<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-2492984514450821757gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">______________________________<wbr>__________________________<br>Jonathan D. Slavin                 Harvard-Smithsonian CfA<br><a href="mailto:jslavin@cfa.harvard.edu" target="_blank">jslavin@cfa.harvard.edu</a>       60 Garden Street, MS 83<br>phone: <a href="tel:(617)%20496-7981" value="+16174967981" target="_blank">(617) 496-7981</a>       Cambridge, MA 02138-1516<br>cell: <a href="tel:(781)%20363-0035" value="+17813630035" target="_blank">(781) 363-0035</a>             USA<br>______________________________<wbr>__________________________<br><br></div></div></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
<br></blockquote></div><br></div>