如何通过给出边的绘制顺序来通过 networkx 绘制图形?

How can draw a graph by networkx by giving the edges order to draw?

我想通过 networkx 按边顺序绘制图形。在我的数据集中,有许多交通方式可供选择,但由于公交车占主导地位,因此无法看到这些方式。如何在总线顶部绘制订单边缘?

colors_p = nx.get_edge_attributes(net_p, 'color').values()
ax2 = fig.add_subplot(1, 3, 2)
nx.draw_networkx(net_p, ax=ax2,pos=nx.get_node_attributes(net_p, 'pos'), with_labels=False, node_size=0.5,
                     alpha=0.5, node_color = 'black', edge_color = colors_p)


ax2.get_xaxis().set_visible(False)
ax2.get_yaxis().set_visible(False)
proxies = [make_proxy(clr, lw=5) for clr in edge_types.keys()]
labels = [edge_type for clr, edge_type in edge_types.items()]
ax2.set_title('pspace')
plt.legend(proxies, labels);

您可以绘制图表 element-wise。

而不是调用 nx.draw_networkx() 以其认为合适的方式绘制图表

首先提取边的子集(例如,“轨道”边)并使用 nx.draw_networkx_edges() 绘制它们。然后提取“电车”边缘并再次用 nx.draw_networkx_edges() 绘制它们。最终,绘制具有相同功能的“总线”边缘 - 它们将位于其他所有内容之上。

最后用nx.draw_networkx_nodes()绘制节点。