我创建了一个带有边缘属性的图形(例如r
,等r=23
).
如何仅使用值显示边缘标签,23
而不是{'r':'23'}
.
相关的源代码如下:
# build a graph G.add_edge(u, v, r=value) # plot the graph pos = nx.spring_layout(G, scale=2) nx.draw(G, pos) edge_labels = nx.get_edge_attributes(G,'r') nx.draw_networkx_edge_labels(G, pos, labels = edge_labels) plt.savefig(out_file)
Joel.. 11
该命令draw_networkx_edge_labels
需要参数edge_labels
而不是`标签.
所以你需要换nx.draw_networkx_edge_labels(G, pos, labels = edge_labels)
到nx.draw_networkx_edge_labels(G, pos, edge_labels = edge_labels)
该命令draw_networkx_edge_labels
需要参数edge_labels
而不是`标签.
所以你需要换nx.draw_networkx_edge_labels(G, pos, labels = edge_labels)
到nx.draw_networkx_edge_labels(G, pos, edge_labels = edge_labels)