py3js: D3.js interface to Python

Python wheel. PyPI PyPI - License

D3JS is awesome, but such a pain to use from Python! This package aims to simplify that. This project was created to great. Originally created because I loved how d3-force works, but replicating it in Python/Jupyter was a real hassle. For instance, with this short snippet

g = ForceDirectedGraph(800, 200)

nodes = ["dev", "pre-prod", "prod", "developers", "testers", "managers"]
colours = ["green", "green", "green", "blue", "blue", "blue"]

for n, c in zip(nodes, colours):
    g.add_nodes(Node(n, color=c))

    # link process
    g.add_links(Link("dev", "pre-prod"))
    g.add_links(Link("pre-prod", "prod"))

    # link involved
    g.add_links(Link("developers", "dev"))
    g.add_links(Link("developers", "pre-prod"))
    g.add_links(Link("testers", "pre-prod"))
    g.add_links(Link("managers", "prod"))

you can easily produce the following output (it’s live, try to interact with the mouse!)

More Samples

Labels and Strokes

Multiple Node Levels

Small Subset of Twitter Data

Word Cloud

P.S. Source on GitHub.


To contact me, send an email anytime or leave a comment below.