我运行的是Windows10,当我运行一个使用matplotlib.pyplot创建绘图的脚本时,如果我在vscode的嵌入式终端( bash或powershell)中运行,则不会创建绘图。但是,图形窗口显示在我的任务栏中,但我无法打开它。
当我在jupyter中运行脚本时,我仍然得到了一个图。当我在'Terminal‘应用程序中运行脚本时,我也会得到一个绘图窗口。因此,我认为这个问题与vscode有关。
我使用的代码非常简单:
import matplotlib.pyplot as plt
x = [1, 1]
plt.plot(x)
plt.show()发布于 2021-02-09 23:27:03
在脚本中绘制图形时,请确保使用以下命令输出显示图形的窗口。
plt.show()默认情况下,Jupyter输出图形,即使没有显式调用plt.show()。
发布于 2021-11-13 12:04:56
在Visual Studio Code Jupyter Notebook中,您可能会看到类似以下内容:

为了显示该图,您可以单击
符号,并将mime类型更改为image/png (Jupyter渲染器)。
现在,绘图出现了。
发布于 2021-08-04 11:25:37
试用最新版本的matplotlib
pip install matplotlib --upgrade这对我来说很好。
https://stackoverflow.com/questions/66121948
复制相似问题