【发布时间】:2021-04-10 00:12:52
【问题描述】:
我正在尝试使用networkx 和matplotlib,我想在将鼠标悬停在节点上时获取节点的名称。我正在尝试使用 mpld3 库,但似乎遇到了递归错误。
graph_nx = graph.to_networkx(max_vertices)
pos = nx.spring_layout(graph_nx)
fig, ax = plt.subplots(subplot_kw=dict(facecolor='#EEEEEE'))
scatter = nx.draw_networkx_nodes(graph_nx, pos, ax=ax, node_size=120)
nx.draw_networkx_edges(graph_nx, pos, ax=ax, width=0.5)
labels = graph_nx.nodes().keys()
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=labels)
mpld3.plugins.connect(fig, tooltip)
mpld3.show()
这就是我现在拥有的。
【问题讨论】:
-
当你有错误时,把它放在帖子上,而不是仅仅提及你有它。
标签: python matplotlib networkx