AttributeError: module 'matplotlib.cbook' has no attribute 'is_numlike' in Networkx
AttributeError: module 'matplotlib.cbook' has no attribute 'is_numlike' in Networkx
我已经阅读了很多关于如何修复这个错误的问题以及他们的答案,但不幸的是我还没有修复这个错误。错误是:
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'
和代码
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)
我使用的是 3.2.2 版的 matplotlib 和 Jupyter Notebook (Python 3)。
我和你有同样的问题
而且我一直在网上搜索,发现了类似 this
的问题
经过尝试,发现问题出在pkg:networkx和pkg:matplotlib版本不匹配,所以卸载重装包即可解决上述问题
所以也许你可以升级或降级networkx/matplotlib来解决你的问题。
希望能帮到你!
我已经阅读了很多关于如何修复这个错误的问题以及他们的答案,但不幸的是我还没有修复这个错误。错误是:
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'
和代码
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)
我使用的是 3.2.2 版的 matplotlib 和 Jupyter Notebook (Python 3)。
我和你有同样的问题
而且我一直在网上搜索,发现了类似 this
的问题经过尝试,发现问题出在pkg:networkx和pkg:matplotlib版本不匹配,所以卸载重装包即可解决上述问题
所以也许你可以升级或降级networkx/matplotlib来解决你的问题。
希望能帮到你!