user12809368
user12809368

Reputation:

AttributeError: module 'matplotlib.cbook' has no attribute 'is_numlike' in Networkx

I have read many questions on how to fix this error as well as their answers, but unfortunately I have not fixed this error yet. The error is:

AttributeError                            Traceback (most recent call last)
<ipython-input-12-665806e1362f> in <module>
     21 G.remove_nodes_from(list(nx.isolates(G)))
     22 
---> 23 nx.draw_networkx(G)

/anaconda3/lib/python3.7/site-packages/networkx/drawing/nx_pylab.py in draw_networkx(G, pos, arrows, with_labels, **kwds)
    276 
    277     node_collection = draw_networkx_nodes(G, pos, **kwds)
--> 278     edge_collection = draw_networkx_edges(G, pos, arrows=arrows, **kwds)
    279     if with_labels:
    280         draw_networkx_labels(G, pos, **kwds)

/anaconda3/lib/python3.7/site-packages/networkx/drawing/nx_pylab.py in draw_networkx_edges(G, pos, edgelist, width, edge_color, style, alpha, arrowstyle, arrowsize, edge_cmap, edge_vmin, edge_vmax, ax, arrows, label, node_size, nodelist, node_shape, **kwds)
    609         # value globally, since the user can instead provide per-edge alphas
    610         # now.  Only set it globally if provided as a scalar.
--> 611         if cb.is_numlike(alpha):
    612             edge_collection.set_alpha(alpha)
    613 

AttributeError: module 'matplotlib.cbook' has no attribute 'is_numlike'

and the code

matches = test[test['Text']>.08]['Name'].tolist()
edges = itertools.product(matches, matches)

G = nx.Graph()
G.add_nodes_from(test['Name'])
G.add_edges_from(edges)
G.remove_nodes_from(list(nx.isolates(G)))


plt.figure(figsize=(70,70))

nx.draw_networkx(G)

I am using version 3.2.2 of matplotlib and Jupyter Notebook (Python 3).

Upvotes: 1

Views: 2783

Answers (1)

zhaocy
zhaocy

Reputation: 72

I have the same problem as you.

And I've been searching online and found the issue like this

After trying, it is found that the problem comes from the pkg:networkx and pkg:matplotlib versions do not match, so the above problem can be solved by uninstalling and reinstalling the package.

So maybe you can upgrade or downgrade networkx/matplotlib to solve you problem.

Hope I can help you!

Upvotes: 1

Related Questions