From: Michael R. <raw...@ya...> - 2011-04-19 20:09:31
|
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 |