在VS代码中使用DevContainer,如何显示Matplotlib图?
我正在 VS Code 中运行 Ubuntu devcontainer。但是,当我运行创建绘图的 python 脚本时,即使使用 matplotlib.pyplot.show() ,绘图也不会显示在任何地方。我的猜测是 devcontainer 没有任何方式来显示它。我现在的解决方法是使用 matplotlib.pyplot.savefig() 保存绘图,但当我只想快速检查某些内容时,这不太好。
有谁知道如何查看 devcontainer 内创建的图?
这是我想做的一个例子:
import matplotlib.pyplot as plt
import numpy as np
# random data
x = np.linspace(0, 1, 100)
y = np.sin(np.pi * x)
# try plotting
plt.plot(x, y)
plt.show()
I'm running an Ubuntu devcontainer inside VS Code. However, when I run a python script that creates a plot, the plot doesn't show up anywhere, even when using matplotlib.pyplot.show()
. My guess is that the devcontainer just doesn't have any way of displaying it. My workaround right now is to save the plot using matplotlib.pyplot.savefig()
, but that's not great when I just want to check something quickly.
Does anyone know how to see the plots created inside the devcontainer?
Here's an example of what I'd like to do:
import matplotlib.pyplot as plt
import numpy as np
# random data
x = np.linspace(0, 1, 100)
y = np.sin(np.pi * x)
# try plotting
plt.plot(x, y)
plt.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论