Circle plots in Lightning

Setup

In [1]:

```
from lightning import Lightning
from numpy import random, asarray
```

In [2]:

```
lgn = Lightning(ipython=True, host='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 [3]:

```
connections = random.rand(50,50)
connections[connections<0.98] = 0
lgn.circle(connections)
```

Out[3]:

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 [4]:

```
connections = random.rand(50,50)
connections[connections<0.98] = 0
lgn.circle(connections, labels=['node ' + str(x) for x in range(50)])
```

Out[4]:

Adding groups

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 [5]:

```
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[5]:

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 [6]:

```
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[6]: