def on_draw(dt): window.clear() points.draw() # lin-lin transform = Position(LinearScale('.xy', domain=(0,10))) # log-lin transform = Position(LogScale('.x', domain=(-1,1)), LinearScale('.y', domain=(0,10))) # lin-log transform = Position(LinearScale('.x', domain=(0,10)), LogScale('.y', domain=(-1,1))) # log-log # transform = Position(LogScale('.xy', domain=(-1,1))) points = PointCollection("agg", transform = transform, color='local') X = np.linspace(0.01,10.0,10000).reshape(10000,1) Z = np.zeros((len(X),1)) points.append(np.hstack((X, X, Z)), color=(1,0,0,1)) points.append(np.hstack((X, np.log(X), Z)), color=(0,1,0,1)) points.append(np.hstack((X, 10**X, Z)), color=(0,0,1,1)) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. # Distributed under the (new) BSD License. # ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.graphics.collections import PointCollection from glumpy.transforms import LinearScale, Position, Viewport window = app.Window(1024,1024, color=(1,1,1,1)) @window.event def on_draw(dt): window.clear() points.draw() @window.event def on_mouse_scroll(x,y,dx,dy): if dy < 0: transform["domain"] = 1.1*transform["domain"] else: transform["domain"] = transform["domain"]/1.1 transform = Position(LinearScale()) points = PointCollection("agg", transform = transform) points.append( P = np.random.normal(0,.5,(10000,3)) ) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
# ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.graphics.collections import PointCollection from glumpy.transforms import LogScale, LinearScale, PolarProjection, Position, Viewport window = app.Window(1024,1024, color=(1,1,1,1)) @window.event def on_draw(dt): window.clear() points.draw() transform = Position(PolarProjection( LogScale('.x', domain=(-1,3), range=(0,1)), LinearScale('.y', domain=(0,2*np.pi), range=(0,2*np.pi)))) points = PointCollection("agg", transform = transform) n = 10000 R = np.random.uniform(0,1000,n) T = np.random.uniform(0,2*np.pi,n) Z = np.zeros(n) points.append (np.dstack((R,T,Z)).reshape(n,3) ) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
@window.event def on_draw(dt): window.clear() points.draw() # lin-lin transform = Position(LinearScale('.xy', domain=(0, 10))) # log-lin transform = Position(LogScale('.x', domain=(-1, 1)), LinearScale('.y', domain=(0, 10))) # lin-log transform = Position(LinearScale('.x', domain=(0, 10)), LogScale('.y', domain=(-1, 1))) # log-log # transform = Position(LogScale('.xy', domain=(-1,1))) points = PointCollection("agg", transform=transform, color='local') X = np.linspace(0.01, 10.0, 10000).reshape(10000, 1) Z = np.zeros((len(X), 1)) points.append(np.hstack((X, X, Z)), color=(1, 0, 0, 1)) points.append(np.hstack((X, np.log(X), Z)), color=(0, 1, 0, 1)) points.append(np.hstack((X, 10**X, Z)), color=(0, 0, 1, 1)) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
window = app.Window(1024, 1024, color=(1, 1, 1, 1)) @window.event def on_draw(dt): window.clear() points.draw() @window.event def on_mouse_scroll(x, y, dx, dy): if dy < 0: transform["exponent"] = np.minimum(10.0, 1.1 * transform["exponent"]) else: transform["exponent"] = np.maximum(0.1, transform["exponent"] / 1.1) transform = Position(PowerScale()) transform["exponent"] = 2 transform["domain"] = -10, +10 points = PointCollection("agg", transform=transform) P = np.random.uniform(-100, 100, (10000, 3)) P = np.copysign(np.sqrt(abs(P)), P) points.append(P) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
from glumpy import app from glumpy.graphics.collections import PointCollection from glumpy.transforms import LogScale, LinearScale, PolarProjection, Position, Viewport window = app.Window(1024, 1024, color=(1, 1, 1, 1)) @window.event def on_draw(dt): window.clear() points.draw() transform = Position( PolarProjection( LogScale('.x', domain=(-1, 3), range=(0, 1)), LinearScale('.y', domain=(0, 2 * np.pi), range=(0, 2 * np.pi)))) points = PointCollection("agg", transform=transform) n = 10000 R = np.random.uniform(0, 1000, n) T = np.random.uniform(0, 2 * np.pi, n) Z = np.zeros(n) points.append(np.dstack((R, T, Z)).reshape(n, 3)) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
# ----------------------------------------------------------------------------- # Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. # Distributed under the (new) BSD License. # ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.graphics.collections import PointCollection window = app.Window(1024, 1024, color=(1, 1, 1, 1)) points = PointCollection("agg", color="local", size="local") @window.event def on_draw(dt): window.clear() points.draw() if len(points) < 100000: points.append(np.random.normal(0.0, 0.5, (1, 3)), color=np.random.uniform(0, 1, 4), size=np.random.uniform(1, 24, 1)) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
# ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.graphics.collections import PointCollection from glumpy.transforms import LinearScale, Position, Viewport window = app.Window(1024, 1024, color=(1, 1, 1, 1)) @window.event def on_draw(dt): window.clear() points.draw() @window.event def on_mouse_scroll(x, y, dx, dy): if dy < 0: transform["domain"] = 1.1 * transform["domain"] else: transform["domain"] = transform["domain"] / 1.1 transform = Position(LinearScale()) points = PointCollection("agg", transform=transform) points.append(P=np.random.normal(0, .5, (10000, 3))) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
# Distributed under the (new) BSD License. # ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.graphics.collections import PointCollection from glumpy.transforms import LogScale, Position, Viewport window = app.Window(1024,1024, color=(1,1,1,1)) @window.event def on_draw(dt): window.clear() points.draw() @window.event def on_mouse_scroll(x,y,dx,dy): if dy < 0: transform["base"] = np.minimum(20., 1.1*transform["base"]) else: transform["base"] = np.maximum(1., transform["base"]/1.1) transform = Position(LogScale()) transform["domain"] = -1,2 # = [base^-1, base^2] points = PointCollection("agg", transform = transform) P = np.random.uniform(0,10,(10000,3)) points.append(P*P) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
#! /usr/bin/env python # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # Copyright (c) 2014, Nicolas P. Rougier # Distributed under the (new) BSD License. See LICENSE.txt for more info. # ----------------------------------------------------------------------------- import numpy as np from glumpy import app from glumpy.transforms import Position, Viewport from glumpy.graphics.collections import PointCollection window = app.Window(1024, 1024, color=(1, 1, 1, 1)) points = PointCollection("agg", color="shared") #points.append(np.random.normal(0.0,0.5,(10000,3)), itemsize=5000) #points["color"] = (1,0,0,1), (0,0,1,1) #points["viewport"].transform = True #points["viewport"].clipping = True #points["viewport"].viewport = 256,256,512,512 @window.event def on_draw(dt): window.clear() points.draw() points.append(np.random.normal(0.0, 0.5, (1, 3))) window.attach(points["transform"]) window.attach(points["viewport"])
from glumpy.graphics.collections import PointCollection from glumpy.transforms import PowerScale, Position, Viewport window = app.Window(1024,1024, color=(1,1,1,1)) @window.event def on_draw(dt): window.clear() points.draw() @window.event def on_mouse_scroll(x,y,dx,dy): if dy < 0: transform["exponent"] = np.minimum(10.0, 1.1*transform["exponent"]) else: transform["exponent"] = np.maximum(0.1, transform["exponent"]/1.1) transform = Position(PowerScale()) transform["exponent"] = 2 transform["domain"] = -10,+10 points = PointCollection("agg", transform = transform) P = np.random.uniform(-100,100,(10000,3)) P = np.copysign(np.sqrt(abs(P)),P) points.append(P) window.attach(points["transform"]) window.attach(points["viewport"]) app.run()
red[idx] = 0.0 green[idx] = 0.0 blue[idx] = 1.0 alpha[idx] = 1.0 radius = np.ones_like(t) radius[0] = 10 points = gloo.Program(vertex, fragment, count=len(x)) points['a_position'] = np.dstack((x, y, z))[0] points['transform'] = Trackball(Position('a_position')) points['a_color'] = np.dstack((red, green, blue, alpha))[0] points['a_radius'] = radius window.attach(points['transform']) pidx = 0 pointsCol = PointCollection('agg', color='local', size='local') window.attach(pointsCol['transform']) # window.attach(pointsCol['viewport']) if os.path.isfile('active_site.pt'): print('... plot with active_site.pt') data = np.genfromtxt('active_site.pt', dtype=[('x', 'f8'), ('y', 'f8'), ('z', 'f8')]) apoint = gloo.Program(vertex, fragment, count=len(data)) apoint['a_position'] = np.dstack((data['x'], data['y'], data['z']))[0] apoint['a_color'] = (0, 0.5, 0, 0.8) apoint['a_radius'] = 5 apoint['transform'] = Trackball(Position('a_position')) window.attach(apoint['transform'])
def start_visualizing(cluster_points, frame_to_show): window = app.Window(DIM, DIM, color=(BLACK if BLACK_ON_WHITE else (1, 2, 1, 1))) point_collection = PointCollection("agg", color="local", size="local") paths = PathCollection(mode="agg") @window.event def on_draw(dt): global FRAME_N window.clear() point_collection.draw() if not cluster_points.empty(): possible = cluster_points.get() print "frame", FRAME_N FRAME_N += 1 if frame_to_show > -1 and not (FRAME_N - 1) == frame_to_show: while not possible == TERMINATOR: possible = cluster_points.get() return time.sleep(DRAW_DELAY) while len(point_collection) > 0: del point_collection[0] while len(paths) > 0: del paths[0] while not possible == TERMINATOR: if FILE == possible[0]: print possible[1] possible = cluster_points.get() continue if ALL_DONE == possible: print "Quitting" app.quit() sys.exit() break if len(possible) == 4: type, data, color, size = possible if POINT == type: new_point = [[0.7 * x for x in data]] new_point[0][1] *= -1 point_collection.append(new_point, color=color, size=size) elif LINE == type: path = [] for hop in data: new_hop = [round(0.7 * abs(x), 5) for x in hop] path.append(new_hop) path = np.asarray(path) print path, len(path) paths.append(path, closed=True, itemsize=len(path)) paths["linewidth"] = 3.0 possible = cluster_points.get() window.attach(point_collection["transform"]) window.attach(point_collection["viewport"]) app.run()