def callback(br, m): _ = users, sct # FIXME: ip only seems to take local and global; sct is neither.. newsizes = np.array(map(m.ix[0].similarity, users)) * 30 #s = sct.get_sizes() #s[:] = newsizes sct._sizes = newsizes ip()
def example(): # pl.ioff() pl.ion() import pandas from numpy.random import uniform n = 25 m = pandas.DataFrame({ 'x': uniform(-1, 1, size=n), 'y': uniform(-1, 1, size=n), 'size': uniform(3, 10, size=n) ** 2, 'color': uniform(0, 1, size=n), }) # test using a custom index m['silly_index'] = ['%sth' % x for x in range(n)] m.set_index('silly_index', drop=True, inplace=True, verify_integrity=True) print m ax = pl.subplot(111) plt = ax.scatter(m['x'], m['y']) b = LassoBrowser(m, ax) print b.idxs #from viz.interact.pointbrowser import PointBrowser #pb = PointBrowser(m, plot=plt) pl.show() ip()
def example(): # pl.ioff() pl.ion() import pandas from numpy.random import uniform n = 25 m = pandas.DataFrame({ 'x': uniform(-1, 1, size=n), 'y': uniform(-1, 1, size=n), 'size': uniform(3, 10, size=n)**2, 'color': uniform(0, 1, size=n), }) # test using a custom index m['silly_index'] = ['%sth' % x for x in range(n)] m.set_index('silly_index', drop=True, inplace=True, verify_integrity=True) print m ax = pl.subplot(111) plt = ax.scatter(m['x'], m['y']) b = LassoBrowser(m, ax) print b.idxs #from viz.interact.pointbrowser import PointBrowser #pb = PointBrowser(m, plot=plt) pl.show() ip()
def callback(event): print 'callback:', event ax = event.inaxes pl.ion() newfig = pl.figure() ax.set_figure(newfig) newfig.set_axes([ax]) newfig.canvas.show() ip()
def icons(users, distance): """Visualization using user profile images as the points.""" # It would be pretty cool to put user thumbails where points are. # but i'm still not sure how to do this yet. images = [] try: print 'getting images..' for p in users: print p f = p.image img = imread('image.tmp') images.append(img) except Exception as e: print 'got an error...' import traceback etype, evalue, tb = sys.exc_info() print yellow % '\n'.join(traceback.format_exception(etype, evalue, tb)) ip() (W, H, _) = shape(img) # thumbnails should all be the same size count = len(images) pl.figure() P2, _ = mds(distance, 2) X,Y = P2[:,0], P2[:,1] ## XXX: not a great transformation b/c we might stretch more in one dimension def N(x): "force x to fit in interval [0,1]" x = (x - x.min()) x = x / x.max() assert all(x >= 0) and all(x <= 1) return x X = N(X)*475 Y = N(Y)*425 figimages = [pl.figimage(img, xo=x, yo=y) for img, x, y in zip(images, X, Y)]