Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 65:75cf537b8d88
moved and generalized map making functions to the library
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 07 Nov 2010 01:09:50 -0500 |
parents | 8aed225f71d8 |
children | 46ec876ce90e |
line wrap: on
line diff
--- a/python/utils.py Fri Nov 05 11:07:44 2010 -0400 +++ b/python/utils.py Sun Nov 07 01:09:50 2010 -0500 @@ -132,6 +132,20 @@ colors = PlottingPropertyValues('brgmyck') # 'w' +def plotIndicatorMap(indicatorMap, squareSize): + from numpy import array, arange, ones, ma + from matplotlib.pyplot import pcolor + coords = array(indicatorMap.keys()) + minX = min(coords[:,0]) + minY = min(coords[:,1]) + X = arange(minX, max(coords[:,0])+1.1)*squareSize + Y = arange(minY, max(coords[:,1])+1.1)*squareSize + C = -ones((len(Y), len(X))) + for k,v in indicatorMap.iteritems(): + C[k[1]-minY,k[0]-minX] = v + masked = ma.masked_where(C<0,C) + pcolor(X, Y, masked) + ######################### # file I/O section #########################