Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

networkx draw graph deprecated message

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")

like image 775
TPike Avatar asked Feb 17 '17 10:02

TPike


4 Answers

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'.

like image 134
Jesse Avatar answered Nov 14 '22 09:11

Jesse


I was able to get rid of the message by going into the networkx library and simply placing # in front of the lines which produced the error.

I would infer the .hold() function is no longer necessary, nor does it need ot be replaced

like image 3
TPike Avatar answered Nov 14 '22 10:11

TPike


I could get nx.draw(G) to work by adding the following line of command:

%matplotlib inline

like image 3
Nithya Mahadevan Avatar answered Nov 14 '22 09:11

Nithya Mahadevan


As error suggest ... I change nx_pylab.py at 611

#       if cb.is_numlike(alpha):
        if isinstance(alpha,numbers.Number):  
like image 2
cobranet Avatar answered Nov 14 '22 10:11

cobranet