Please help.... TypeError: draw_networkx_edge_labels() got an unexpected keyword argument 'labels'

662 views
Skip to first unread message

Chris Franklin

unread,
Aug 4, 2021, 6:52:19 PM8/4/21
to networkx-discuss
Hi everyone,
I am getting this error when trying to populate nodes with attributes.
The Trace error refers to line 19 of this cell. Please advise Thanks Chrisnetworkx_visualization_helper_file_pic.PNG


networkx_errorpic2.PNG
Line withe trace error
--> 19 nx.draw_networkx_edge_labels(G, pos=pos, labels = edge_labels)

here is a the cell as well
uk_places.nodes['London']['population'] = 8000000
uk_places.nodes['Manchester']['population'] = 5000000
uk_places.nodes['Leeds']['population'] = 470000
view_graph(uk_places)

Nodes in graph: ['London', 'Manchester', 'Leeds'] Edges in graph: [('London', 'Manchester'), ('London', 'Leeds'), ('Manchester', 'Leeds')]
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-90-0323bcce71b0> in <module> 2 uk_places.nodes['Manchester']['population'] = 5000000 3 uk_places.nodes['Leeds']['population'] = 470000 ----> 4 view_graph(uk_places) <ipython-input-30-d3b0875fb448> in view_graph(G) 17 if len(nx.get_edge_attributes(G,'distance')) != 0: 18 edge_labels = nx.get_edge_attributes(G, 'distance') ---> 19 nx.draw_networkx_edge_labels(G, pos=pos, labels = edge_labels) 20 plt.figure(figsize=(12,12)) 21 plt.show() 
 TypeError: draw_networkx_edge_labels() got an unexpected keyword argument 'labels'



Dan Schult

unread,
Aug 4, 2021, 10:45:29 PM8/4/21
to networkx...@googlegroups.com
The keyword argument you want is `edge_labels=edge_labels`   not `labels=edge_labels`.


Reply all
Reply to author
Forward
0 new messages