Draw graph in NetworkX
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