gpt4 book ai didi

image - 避免

转载 作者:行者123 更新时间:2023-12-02 08:14:15 25 4
gpt4 key购买 nike

我试图在同一张图上绘制一系列函数。代码似乎运行正常,但是没有图片出来。只是简单的

<matplotlib.figure.Figure at 0xeafea58>

如何修复?

最佳答案

在 IPython 控制台中,确保图形显示(无需显式调用 plt.show())的最佳方法是使用 %matplotlib 模式。如果 matplotlib 安装正确,它应该会自动为您的系统选择合适的后端。

例如:

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot([1, 2, 3]) # no plot shown!
Out[2]: [<matplotlib.lines.Line2D at 0x110eac898>]

In [3]: %matplotlib
Using matplotlib backend: MacOSX

In [4]: plt.plot([1, 2, 3]) # plot shown now
Out[4]: [<matplotlib.lines.Line2D at 0x112174400>]

enter image description here

%matplotlib 魔术命令每个 session 只需输入一次。

关于image - 避免 <matplotlib.figure.Figure at 0xeafea58>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43504109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com