一、问题描述
在使用networkx
进行图数据可视化时报错如题'_AxesStack' object is not callable while using networkx to plot
。其中matplotlib为3.6.2版本,networkx版本为2.7。
import matplotlib.pyplot as plt
import networkx as nx
plt.figure(figsize=(15,14))
pos = nx.spring_layout(G, iterations=3, seed=5)
nx.draw(G, pos, with_labels=True)
# nx.draw_networkx(G, pos, with_labels = True)
plt.savefig("east_travel.jpg")
plt.show()
二、解决方法
- 将netwokx升级为最新版本
- 或直接将
nx.draw
改为nx.draw_networkx
nx.draw_networkx(G, pos, with_labels = True)
Reference
[1] ‘_AxesStack’ object is not callable while using networkx to plot. stackoverflow