【发布时间】:2019-08-06 14:01:57
【问题描述】:
我正在尝试使用 NetworkX 库在有向图的两个节点之间添加弯曲箭头。
函数nx.draw_networkx_edges 的文档提到了参数connectionstyle。设置connectionstyle='arc3, rad = 0.2' 应该产生弯曲的连接器。但我无法重现这一点。
我还查看了模块matplotlib.patches 并调用ConnectionStyle,如https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.ConnectionStyle.html 中所述;但我仍然得到相同的视觉效果。
array_of_edges = list(zip(df.start_node, df.end_node, df.weight))
G.add_weighted_edges_from(array_of_edges)
nx.draw_networkx_edges(
G, pos_nodes,
edge_color='#5B174C',
width=df['weight'] / 600,
alpha=0.8,
connectionstyle='arc3,rad=0.2')
这就是我得到的,这就是我需要的: https://imgur.com/a/1TcPfY9
【问题讨论】:
标签: python-3.x matplotlib networkx