tools/plot-values/plot.py
 author Dmitriy Morozov Tue, 04 Aug 2009 14:28:17 -0700 branch dev changeset 149 3d15aca95dfb parent 141 cda0b85ffc50 permissions -rwxr-xr-x
Simplices are deleted from the complex after removal in triangle-zigzag.py + touched up documentation (to mention CohomologyPersistence better)
```
#!/usr/bin/env python

from    pylab           import scatter, show, cm, colorbar, savefig, axis, \
from    itertools       import izip
from    sys             import argv, exit
import  os.path         as     osp

def plot(val_fn, pts_fn, output_fn):
points = []
with open(pts_fn) as fp:
points.append(map(float, line.split()))

values = []
with open(val_fn) as fp:
values.append(float(line.split()[1]))

xx = [pt[0] for pt in points]
yy = [pt[1] for pt in points]
print "X:", min(xx), max(xx)
print "Y:", min(yy), max(yy)

m = min(values)
values = [(v-m) % 1. for v in values]
print "V:", min(values), max(values)

# hsv()
fig = figure()
scatter(xx,yy,s=10,c=values)
colorbar()

ax = axes()
ax.set_axis_off()
ax.set_aspect('equal', 'box')

fig.savefig(output_fn)

if __name__ == '__main__':
if len(argv) < 3:
print "Usage: %s VALUES POINTS" % argv[0]
exit()

val_fn = argv[1]
pts_fn  = argv[2]
output_fn, ext = osp.splitext(val_fn)
output_fn += '.pdf'
plot(val_fn, pts_fn, output_fn)
```