matplot的plot对象如何转换成numpy矩阵?

matplot的plot对象如何转换成numpy矩阵?

fig, ax = plt.subplots()
nx.draw(self.g1, ax=ax,node_size=20)
fig.canvas.draw()
data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
self.ivGeneNetwork.setImage(data)
posted @ 2022-08-20 16:54  bH1pJ  阅读(27)  评论(0编辑  收藏  举报