1

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

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.