networkx draw graph deprecated message

TPike picture TPike · Feb 17, 2017 · Viewed 14.6k times · Source

I am trying to draw a graph networkx using python 3.6 with Jupyter notebook and the network package with anaconda. But the graph is not drawing per the documentation, I am just getting a deprecated message.

CODE:

import networkx as nx
import csv
import matplotlib as plt

G = nx.read_pajek('Hi-tech.net')

nx.draw(G) 

MESSAGE:

MatplotlibDeprecationWarning: pyplot.hold is deprecated. Future behavior will be consistent with the long-time default: plot commands add elements without first clearing the Axes and/or Figure.

b = plt.ishold()

Future behavior will be consistent with the long-time default: plot commands add elements without first clearing the Axes and/or Figure.

plt.hold(b)

warnings.warn("axes.hold is deprecated, will be removed in 3.0")

Answer

Jesse picture Jesse · May 8, 2017

To avoid this warning, I just simply replace

nx.draw(G)

by

nx.draw_networkx(G)

My Python is 3.4, Jupyter '1.0.0' and networkx '1.11'.