To clarify, you are trying to read in a set of (lat,lon) points in a file
that is space delimited, store the data, and then put a text marker at each
point, with each point numbered in order?  The critical part is that you
want to use a list (or numpy array) instead of a dictionary.  Something like
this ought to do (don't have MPL on this computer though - pretty sure this
should work):

lines=open('file.txt','r').readlines()
(lats,lons)=([],[])
for line in lines:
    (lat,lon)=line.strip().split(' ')
    lats.append(float(lat))
    lons.append(float(lon))

for i in range(len(lons)):
    plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')

I'm sure there are a bunch of more compact ways to do this, but this should
work.

Ian
----
Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu
cell: (607)227-7626


On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins <rawlin...@yahoo.com>wrote:

>
> I'm trying to plot a series of points/locations on a map. I'm reading the
> latitudes and longitudes from a file, with each lat, lon pair on each record
> (line).  Here is the code:
>
> def make_float(line):
>    lati, longi = line.split()
>    return float(lati), float(longi)
>
> my_dict = {}
> with open("file.txt") as f:
>    for item in f:
>        lati,longi = make_float(item)
>        my_dict[lati] = longi
>
> xpt,ypt = m(-76.1670,39.4670 )
> plt.text(xpt,ypt,'1',color='white')
>
> #print my_dict
>
> The matplotlib code which I've previously used to plot a single point on
> the map is below, with longitude and latitude in ( ):
>
> xpt,ypt = m(-70.758392,42.960445)
> plt.text(xpt,ypt,'1',color='white')
>
> When replacing (-70.758392,42.960445) with (longi,lati), the code plots
> only a single '1' at the location of just the last coordinate pair in the
> file. So now I only need to plot them all. Does the code I've implemented
> have an implicit loop to it?
>
> Mike
>
>
>
>
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to