from lightning import Lightning
from numpy import random, arange, asarray, corrcoef, argsort, array
import networkx as nx
from sklearn import datasets
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')
Connected to server at http://public.lightning-viz.org
Matrices are useful ways to visualize dense tables and correlation matrices data.
mat = random.randn(10,10)
lgn.matrix(mat)
Rectanglular matrices will automatically size appropriately.
mat = random.randn(10,20)
lgn.matrix(mat)
mat = random.randn(20,10)
lgn.matrix(mat)
Matrices can be rendered using any colorbrewer colormaps.
mat = random.rand(10,10)
lgn.matrix(mat, colormap='Reds')
mat = random.rand(10,10)
lgn.matrix(mat, colormap='Spectral')
You can label the rows and columns of a matrix. Clicking on the text labels will highlight those rows and columns -- try it!
n, m = (8, 16)
mat = arange(n*m).reshape(n,m)
rows = ['row ' + str(i) for i in range(n)]
columns = ['col ' + str(i) for i in range(m)]
lgn.matrix(mat, row_labels=rows, column_labels=columns)
You can also turn on labeling of cells by their value.
mat = arange(n*m).reshape(n,m)
lgn.matrix(mat, numbers=True)