Revision: 4671
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4671&view=rev
Author: jswhit
Date: 2007-12-07 18:35:27 -0800 (Fri, 07 Dec 2007)
Log Message:
-----------
really color by pop rank
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotcities.py
Modified: trunk/toolkits/basemap/examples/plotcities.py
===================================================================
--- trunk/toolkits/basemap/examples/plotcities.py 2007-12-07 19:18:58 UTC
(rev 4670)
+++ trunk/toolkits/basemap/examples/plotcities.py 2007-12-08 02:35:27 UTC
(rev 4671)
@@ -1,18 +1,24 @@
import pylab as p
+from matplotlib.mlab import prctile_rank
import numpy
from matplotlib.toolkits.basemap import Basemap as Basemap
# cities colored by population rank.
+
m = Basemap()
shp_info = m.readshapefile('cities','cities')
x, y = zip(*m.cities)
pop = []
for item in m.cities_info:
- pop.append(int(item['POPULATION']))
-pop = numpy.array(pop)
-poprank = numpy.argsort(pop)
+ population = item['POPULATION']
+ if population < 0: continue # population missing
+ pop.append(population)
+popranks = prctile_rank(pop,100)
+colors = []
+for rank in popranks:
+ colors.append(p.cm.jet(float(rank)/100.))
m.drawcoastlines()
m.fillcontinents()
-m.scatter(x,y,25,poprank,cmap=p.cm.jet_r,marker='o',faceted=False,zorder=10)
+m.scatter(x,y,25,colors,marker='o',faceted=False,zorder=10)
p.title('City Locations colored by Population Rank')
p.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins