我维护了一个名为netgraph的用于网络可视化的 python 库,它可以很好地与 networkx 或 igraphGraph对象配合使用。我认为这是一个功能的好主意,所以我只是在dev分支上实现了一个简单的框架版本。

通过 pip 安装:
pip install https://github.com/paulbrodersen/netgraph/archive/dev.zip
重现上述示例的代码:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import networkx as nx
from netgraph import InteractiveGraph
g = nx.cubical_graph()
tables = dict()
for node in g.nodes:
data = np.round(np.random.rand(3,2), decimals=2)
table = pd.DataFrame(data, index=['Lorem', 'ipsum', 'dolor'], columns=['sit', 'amet'])
tables[node] = table
for edge in g.edges:
data = np.round(np.random.rand(4,1), decimals=2)
table = pd.DataFrame(data, index=['consectetur', 'adipiscing', 'elit', 'Mauris'], columns=['sed'])
tables[edge] = table
fig, ax = plt.subplots(figsize=(12,5))
fig.subplots_adjust(right=0.6) # make space for table on the right
bbox = [1.5, 0.1, 0.5, 0.8] # position of the table in axes coordinates
instance = InteractiveGraph(g, node_labels=True, tables=tables, table_kwargs=dict(edges='horizontal', fontsize=16, bbox=bbox), ax=ax)
plt.show()