Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 324:99ca91a46007
minor change
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 09 May 2013 04:02:46 +0200 |
| parents | efd4dd4665ac |
| children | a6ca86107f27 |
comparison
equal
deleted
inserted
replaced
| 323:efd4dd4665ac | 324:99ca91a46007 |
|---|---|
| 285 | 285 |
| 286 ######################### | 286 ######################### |
| 287 # plotting section | 287 # plotting section |
| 288 ######################### | 288 ######################### |
| 289 | 289 |
| 290 def stepPlot(X, firstX, lastX, initialCount = 0): | 290 def stepPlot(X, firstX, lastX, initialCount = 0, increment = 1): |
| 291 '''for each value in x, increment by one the initial count | 291 '''for each value in X, increment by increment the initial count |
| 292 returns the lists that can be plotted | 292 returns the lists that can be plotted |
| 293 to obtain a step plot increasing by one for each value in x, from first to last value''' | 293 to obtain a step plot increasing by one for each value in x, from first to last value |
| 294 firstX and lastX should be respectively smaller and larger than all elements in X''' | |
| 294 | 295 |
| 295 sortedX = [] | 296 sortedX = [] |
| 296 counts = [initialCount] | 297 counts = [initialCount] |
| 297 for x in sorted(X): | 298 for x in sorted(X): |
| 298 sortedX += [x,x] | 299 sortedX += [x,x] |
| 299 counts.append(counts[-1]) | 300 counts.append(counts[-1]) |
| 300 counts.append(counts[-1]+1) | 301 counts.append(counts[-1]+increment) |
| 301 counts.append(counts[-1]) | 302 counts.append(counts[-1]) |
| 302 return [firstX]+sortedX+[lastX], counts | 303 return [firstX]+sortedX+[lastX], counts |
| 303 | 304 |
| 304 class PlottingPropertyValues: | 305 class PlottingPropertyValues: |
| 305 def __init__(self, values): | 306 def __init__(self, values): |
