A nice way of visualizing complex networks are Hiveplots.
This library uses svgwrite to programmatically create images like this one:
Pyveplot is tested on pythons 2.7 and 3.5+
Create a plot from a network, randomly selecting whichever axis to place 50 nodes.
import random
from math import pi
from pyveplot import Hiveplot
import networkx
random.seed(1)
# a network
g = networkx.barabasi_albert_graph(50, 2, seed=2)
# numbers use px units
center = (200, 200)
# our hiveplot object
h = Hiveplot("modern_example.svg", center=center)
axis0 = h.add_axis(start=center, end=(200, 100), stroke="grey")
# polar coordinates (radius, angle): defaults to radians
circle = 2 * pi
# str units are interpreted correctly
axis1 = h.add_axis_polar(end=("105pt", circle / 3), stroke="blue")
axis2 = h.add_axis_polar(end=("5.82cm", 240), use_radians=False, stroke="black")
# randomly distribute nodes in axes
for n in g.nodes():
random.choice(h.axes).add_node(n, random.random())
for e in g.edges():
if (e[0] in axis0.nodes) and (e[1] in axis1.nodes): # edges from axis0 to axis1
h.connect(
axis0,
e[0],
45,
axis1,
e[1],
-45,
stroke_width="0.34",
stroke_opacity="0.4",
stroke="purple",
)
elif (e[0] in axis0.nodes) and (e[1] in axis2.nodes): # edges from axis0 to axis2
h.connect(
axis0,
e[0],
-45,
axis2,
e[1],
45,
stroke_width="0.34",
stroke_opacity="0.4",
stroke="red",
)
elif (e[0] in axis1.nodes) and (e[1] in axis2.nodes): # edges from axis1 to axis2
h.connect(
axis1,
e[0],
15,
axis2,
e[1],
-15,
stroke_width="0.34",
stroke_opacity="0.4",
stroke="magenta",
)
h.save()
The more elaborate example.py shows how to use shapes for nodes, placement of the control points and attributes of edges, and the attributes of axes.
Install library, perhaps within a virtualenv:
pip install pyveplot