import os
from lightning import Lightning
from numpy import random, asarray
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')
Connected to server at http://public.lightning-viz.org
Many plot types let you specify tooltips with the labels
argument and the tooltips=True
setting. First, turn on the setting for a simple scatter plot, and try clicking a point -- you should see it's x and y value appear above.
x = random.rand(10)
y = random.rand(10)
lgn.scatter(x, y, size=10, tooltips=True)
Now let's try adding explicit text labels. We'll make labels maked on random group assignments.
x = random.rand(10)
y = random.rand(10)
g = (random.rand(10) * 5).astype('int')
lgn.scatter(x, y, size=10, labels=['group ' + str(i) for i in g], tooltips=True, group=g)
A common use case for tooltips is in labeling graphs. Here we'll make a simple force network and label the vertices based on a group assignment.
mat = random.rand(25,25)
mat[mat<0.8] = 0
group = (random.rand(25) * 5).astype('int')
labels = ['vertex ' + str(g) for g in group]
lgn.force(mat, labels=labels, group=group)