I'm trying to draw any graph in NetworkX, but get nothing, not even errors:
import networkx as nx import matplotlib.pyplot as plt g1=nx.petersen_graph() nx.draw(g1)
Add to the end:
plt.show()
import networkx as nx import matplotlib.pyplot as plt g1 = nx.petersen_graph() nx.draw(g1) plt.show()
When run from an interactive shell where plt.ion()
has been called, the plt.show()
is not needed. This is probably why it is omitted in a lot of examples.
If you run these commands from a script (where plt.ion()
has not been called), the plt.show()
is needed. plt.ion()
is okay for interactive sessions, but is not recommended for scripts.
in ipython notebook, just type in magic
%matplotlib inline
or
%matplotlib notebook
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With