TPike
TPike

Reputation: 286

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

Upvotes: 17

Views: 16426

Answers (5)

Christian
Christian

Reputation: 23

I just commented out the line 365 of file __init__.py in Lib\site-packages\matplotlib\cbook which reads

@deprecated('3.0', 'isinstance(..., numbers.Number)')

Upvotes: 0

cobranet
cobranet

Reputation: 119

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

#       if cb.is_numlike(alpha):
        if isinstance(alpha,numbers.Number):  

Upvotes: 2

Nithya Mahadevan
Nithya Mahadevan

Reputation: 39

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

%matplotlib inline

Upvotes: 3

Jesse
Jesse

Reputation: 3393

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

Upvotes: 34

TPike
TPike

Reputation: 286

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

Upvotes: 3

Related Questions