# Circle plots in Lightning

## Setup

In :
from lightning import Lightning

from numpy import random, asarray


## Connect to server¶

In :
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org') Lightning initialized
Connected to server at http://public.lightning-viz.org


## Just connections

Circle plots show connections between nodes in a graph as lines between points around a circle. Let's make one for a set of random, sparse connections.

In :
connections = random.rand(50,50)
connections[connections<0.98] = 0

lgn.circle(connections)

Out:

We can add a text label to each node. Here we'll just add a numeric identifier. Clicking on a node label highlights its connections -- try it!

In :
connections = random.rand(50,50)
connections[connections<0.98] = 0

lgn.circle(connections, labels=['node ' + str(x) for x in range(50)])

Out:

Circle plots are useful for visualizing hierarchical relationships. You can specify multiple levels of grouping using a nested list. Let's start with one.

In :
connections = random.rand(50,50)
connections[connections<0.98] = 0

group = (random.rand(50) * 3).astype('int')
lgn.circle(connections, labels=['group ' + str(x) for x in group], group=group)

Out:

## Nested groups

And now try adding a second level. We'll label by the second group to make clear what's going on. If you click on any of the outermost arcs, it will highlight connections to/from that group.

In :
connections = random.rand(50,50)
connections[connections<0.98] = 0

group1 = (random.rand(50) * 3).astype('int')
group2 = (random.rand(50) * 4).astype('int')
lgn.circle(connections, labels=['group ' + str(x) for x in group2], group=[group1, group2])

Out: