Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: draw_networkx_edges() got an unexpected keyword argument 'with_labels' #85

Open
Ru-Zheng opened this issue Aug 23, 2022 · 3 comments

Comments

@Ru-Zheng
Copy link

Ru-Zheng commented Aug 23, 2022

my codes:
import networkx as nx
import EoN
import matplotlib.pyplot as plt

G = nx.watts_strogatz_graph(100, 5, 0.9)
nx_kwargs = {"with_labels": True}

sim = EoN.Gillespie_SIR(G, 1, 0.1, return_full_data=True)

t = 0.0
while t < 40:
sim.display(time=t, **nx_kwargs)
plt.show()
t += 0.5

tree = sim.transmission_tree()
hierarchy_tree = EoN.hierarchy_pos(tree)
nx.draw(tree, hierarchy_tree, with_labels=True)
plt.show()


However,I meet some problem:

Traceback (most recent call last):
File "D:\python_project\sir.py", line 15, in
sim.display(time=t, **nx_kwargs)
File "D:\python3.9.10\lib\site-packages\EoN\simulation_investigation.py", line 875, in display
self.display_graph(pos, nodestatus, nodelist, status_order, statuses_to_plot, graph_ax, **nx_kwargs)
File "D:\python3.9.10\lib\site-packages\EoN\simulation_investigation.py", line 639, in display_graph
nx.draw_networkx_edges(self.G, pos, edgelist=edgelist, ax=ax, **nx_kwargs)
TypeError: draw_networkx_edges() got an unexpected keyword argument 'with_labels'

Can you help me to solve this problem,thank you.

@joelmiller
Copy link
Collaborator

Hi,

Can you give me information about what version of networkx you're running?

This is odd because that code runs okay for me. The error is suggesting that when EoN calls draw_networkx_edges, it is sending an argument that the networkx method isn't expecting.

@Ru-Zheng
Copy link
Author

Hi,
My networkx version is 2.8.2,when I rewrite simulation_investigation.py line 639:nx.draw_networkx_edges(self.G, pos, edgelist=edgelist, ax=ax, **nx_kwargs) to nx.draw_networkx(self.G, pos, edgelist=edgelist, ax=ax, **nx_kwargs), it is worked.

@joelmiller
Copy link
Collaborator

You may want to add nodelist = [] to the edited function call. This was obviously supposed to only draw the edges (with the nodes handled separately), but the version you're calling will also draw all the nodes in this call. I think adding nodelist=[] will prevent that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants