Sample plot using d3


In [12]:
import random
from loganalyser import plot

Graph visualization

Based on http://bl.ocks.org/mbostock/4062045


In [13]:
plot.set_styles(['force_directed_graph'])


Out[13]:

In [14]:
# this code is from: https://github.com/stitchfix/d3-jupyter-tutorial/blob/master/multiple_simple_examples.ipynb
n_nodes = 30
p_edge = 0.05
graph = {"nodes": [], "links": []}
for i in range(n_nodes):
    graph["nodes"].append( {"name": "i" + str(i), "group": int(random.uniform(1,11))} )
for i in range(n_nodes):
    for j in range(n_nodes):
        if random.uniform(0,1) < p_edge:
            graph["links"].append( {"source": i, "target": j, "value": random.uniform(0.5,3)} )

In [15]:
plot.draw_graph('force_directed_graph', graph)


Out[15]:

please use the mouse to drag my nodes!