簡體   English   中英

AttributeError:模塊“matplotlib.cbook”在 Networkx 中沒有屬性“is_numlike”

[英]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)

我正在使用 matplotlib 和 Jupyter Notebook (Python 3) 的 3.2.2 版本。

我和你有同樣的問題。

我一直在網上搜索,發現這樣的問題

嘗試后發現問題出在pkg:networkx和pkg:matplotlib版本不匹配,所以上述問題可以通過卸載重裝package解決。

所以也許你可以升級或降級 networkx/matplotlib 來解決你的問題。

希望我能幫助你!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM