解决‘_AxesStack‘ object is not callable while using networkx to plot

一、问题描述

在使用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

你可能感兴趣的:(#,数据分析,图神经网络GNN,python,networkx,可视化)