相关疑难解决方法(0)

如何自定义networkx中边缘标签的显示?

我创建了一个带有边缘属性的图形(例如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)
Run Code Online (Sandbox Code Playgroud)

python matplotlib networkx

7
推荐指数
1
解决办法
8814
查看次数

标签 统计

matplotlib ×1

networkx ×1

python ×1