Can anyone recommend a Python library that can do interactive graph visualization?
I specifically want something like d3.js but for python
See:
Is there a good interactive 3D graph library out there?
The accepted answer suggests the following program, which apparently has python bindings: http://ubietylab.net/ubigraph/
Edit
I'm not sure about the interactivity of NetworkX, but you can definitely make 3D graphs. There is at least one example in the gallery:
http://networkx.lanl.gov/examples/drawing/edge_colormap.html
And another example in the 'examples'. This one, however, requires that you have Mayavi.
http://networkx.lanl.gov/examples/3d_drawing/mayavi2_spring.html
There is an interesting port of NetworkX to Javascript that might do what you want. See http://felix-kling.de/JSNetworkX/
You could use d3py a python module that generate xml pages embedding d3.js script. For example :
import d3py
import networkx as nx
import logging
logging.basicConfig(level=logging.DEBUG)
G = nx.Graph()
G.add_edge(1,2)
G.add_edge(1,3)
G.add_edge(3,2)
G.add_edge(3,4)
G.add_edge(4,2)
# use 'with' if you are writing a script and want to serve this up forever
with d3py.NetworkXFigure(G, width=500, height=500) as p:
p += d3py.ForceLayout()
p.show()
Try https://altair-viz.github.io/ - the successor of d3py and vincent. See also
You can also choose to serialize your data and then visualize it in D3.js, as done here: Use Python & Pandas to Create a D3 Force Directed Network Diagram (It comes with a jupyter notebook as well!)
Here is the gist. You serialize your graph data in this format:
import json
json_data = {
"nodes":[
{"name":"Myriel","group":1},
{"name":"Napoleon","group":1},
{"name":"Mlle.Baptistine","group":1},
{"name":"Mme.Magloire","group":1},
{"name":"CountessdeLo","group":1},
],
"links":[
{"source":1,"target":0,"value":1},
{"source":2,"target":0,"value":8},
{"source":3,"target":0,"value":10},
{"source":3,"target":2,"value":6},
{"source":4,"target":0,"value":1},
{"source":5,"target":0,"value":1},
]
}
filename_out = 'graph_data.json'
json_out = open(filename_out,'w')
json_out.write(json_data)
json_out.close()
Then you load the data in with d3.js:
d3.json("pcap_export.json", drawGraph);
For the routine drawGraph
I refer you to the link, however.
I've got a good example of automatically generating D3.js network diagrams using Python here: http://brandonrose.org/ner2sna
The cool thing is that you end up with auto-generated HTML and JS and can embed the interactive D3 chart in a notebook with an IFrame