from lightning import Lightning
from numpy import random, asarray, arange
from sklearn import datasets
from scipy.ndimage.filters import gaussian_filter
from seaborn import color_palette
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')
Connected to server at http://public.lightning-viz.org
To experience Lightning's custom zoom behaviors, try zooming and panning with the alt or command keys held down.
y = gaussian_filter(random.rand(100), 3)
lgn.line(y)
For a single line you can pass one size and color.
y = gaussian_filter(random.rand(100), 3)
lgn.line(y, thickness=10, color=[255,100,100])
Colors for multiple lines will automatically be assigned. Try hovering over a line to highlight it!
y = gaussian_filter(random.rand(5,100), [0, 3])
y = (y.T + arange(0,5)*0.2).T
lgn.line(y, thickness=6)
You can also set colors and thicknesses yourself, providing one per line. Here we do so using a palette from seaborn
.
y = gaussian_filter(random.rand(5,100), [0, 3])
y = (y.T + arange(0,5)*0.2).T
c = map(lambda x: list(asarray(x)*255), color_palette('Blues', 5))
s = [8, 10, 12, 14, 16]
lgn.line(y, thickness=s, color=c)
It's possible to show multiple lines of unequal length.
y1 = gaussian_filter(random.rand(50), 5).tolist()
y2 = gaussian_filter(random.rand(75), 5).tolist()
y3 = gaussian_filter(random.rand(100), 5).tolist()
x = range(50,150)
lgn.line([y1,y2,y3], thickness=6, index=x)
Instead of specifying colors directly as rgb, you can specify group assignments.
d, g = datasets.make_blobs(n_features=5, n_samples=20, centers=5, cluster_std=1.0, random_state=100)
lgn.line(d, group=g)
You can also label the axes.
y = gaussian_filter(random.rand(100), 3)
lgn.line(y, thickness=10, xaxis='variable #1', yaxis='variable #2')