I finally found the command I was looking for. It is the
Here is what worked :
# make a LineCollection of contours
for i in np.arange(0,LevelsNumber,1):
All the vertices in each collections are extracted to the "polygoni".
Thanks again to Jeff and Patrick !
By the way, I found out that I do not actually need this procedure to
achieve may goal which was to make a contour plot in ternary coordinates.
On Tue, Jan 27, 2009 at 11:08 PM, Patrick Marsh >> <patrickmarshwx@...287...> wrote:
On Tue, Jan 27, 2009 at 7:16 PM, Eli Brosh <ebrosh1@...287...> >> wrote:
> Many thanks to Jeff and to Patric !
> I will try to work along the line suggested by Jeff.
> Patric, please send me your code.
> I hope to learn from it.
> Thanks again,
models, but should work with any gridded file.
from mpl_toolkits.basemap import Basemap
f = (some gridded file)
X = np.array(grab longitudes from f)
Y = np.array(grab latitudes from f)
field = np.array(grab field to be contoured from f)
map = Basemap(make a Basemap call here)
level = np.arange(minval, maxval, interval)
col = map.contour(X, Y, field, level).collections
for vertex in col[i].get_paths(): # GET THE PATHS FOR THE
CONTOUR BY LOOPING THROUGH CONTOURS
for vertex in xy.vertices: # ITERATE OVER THE PATH
x, y = map(vertex,vertex,inverse=True) #
and now 'x' is the longitude of the vertex and vertex and
is the latitude of the vertex
> On Tue, Jan 27, 2009 at 7:09 PM, Patrick Marsh >> <patrickmarshwx@...287...> >> > wrote:
>> On Tue, Jan 27, 2009 at 5:33 PM, Jeff Whitaker >> <jswhit@...146...> wrote:
>> > Eli Brosh wrote:
>> >> Hello,
>> >> I am trying to extract the coordinates of contour lines.
>> >> I tried the following:
>> >> cs = *contour*(Z)
>> >> for lev, col in zip(cs.levels, cs.collections):
>> >> s = col._segments
>> >> that I found in a previous post (title "contouring", by
>> >> Gómez-Dans-2
>> >> Nov 30, 2007; 07:47am ) .
>> >> I hoped that s will be a list of numpy arrays, each
>> >> (x,y) vertices
>> >> defining a contour line at level lev.
>> >> However, I got an error message:
>> >> AttributeError: 'LineCollection' object has no attribute
>> >> How is it possible to get coordinates of the contours,
similar to the
>> >> MATLAB command
>> >> [C,H] = *CONTOUR*(...)
>> >> where the result in C is the coordinates of the
>> >> A similar question appeared in a post "contour data" (by
>> >> <http://www.nabble.com/user/UserProfile.jtp?user=382945>
May 17, 2006;
>> >> 09:42am) but I could not understand the answer.
>> >> Is it possible to get more specific directions with a
simple example ?
>> >> Thanks
>> >> Eli
>> > Eli: Calling get_paths() on each line collection in
>> > return a list of Path objects. From the Path objects,
you can get a Nx2
>> > array of vertices from the "vertices" attribute. There
are no examples
>> > that I know of, but if you get it to do what you want to
do, it would be
>> > great if you could contribute an example. As you noted,
>> > has come up several times before.
>> > -Jeff
>> > --
>> > Jeffrey S. Whitaker Phone : (303)497-6313
>> > Meteorologist FAX : (303)497-6449
>> > NOAA/OAR/PSD R/PSD1 Email :
>> > 325 Broadway Office : Skaggs Research Cntr
>> > Boulder, CO, USA 80303-3328 Web :
>> > This SF.net email is sponsored by:
>> > SourcForge Community
>> > SourceForge wants to tell your story.
>> > http://p.sf.net/sfu/sf-spreadtheword
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Matplotlibfirstname.lastname@example.org
>> I'm not sure if this is entirely what you (Eli) are looking
for, but I
>> have code that will contour model data on a map and then
>> lat,lon pairs of all the vertices. If this is what you are
>> for, I'm happy to share what I've done.
>> Patrick Marsh
>> Graduate Research Assistant
>> School of Meteorology
>> University of Oklahoma
Graduate Research Assistant
School of Meteorology
University of Oklahoma
This SF.net email is sponsored by:
SourceForge wants to tell your story.
_______________________________________________ Matplotlib-users mailing list Matplotlibemail@example.com https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA