Python - 如何在 Visual Studio Code 本身中显示图形? [英] Python - How to show graph in Visual Studio Code itself?

查看:145
本文介绍了Python - 如何在 Visual Studio Code 本身中显示图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行此示例时:

When I try to run this example:

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()

我会在新窗口中看到结果.

I see the result in a new window.

有什么办法可以直接在 Visual Studio Code 本身中查看结果图吗?

Is there any way to see the result graphs in the Visual Studio Code itself directly?

谢谢.

推荐答案

是的,如果您使用笔记本界面.基本上,安装 Python 扩展包,它包含 Jupyter 扩展,将您的代码放入编辑器中,将 #%% 放在代码的顶部,您将获得 Run cell可点击,点击它,你会在另一个窗口得到结果

Yes, if you use notebook interface. Basically, install Python Extension Pack, it includes Jupyter extension, put your code in the editor, put #%% at the top of your code, you'll get Run cell clickable, click it, and you'll get result in the other window

这是扩展的链接:https://marketplace.visualstudio.com/items?itemName=donjayamanne.jupyter

更新

好的,显然微软聘请了 Don Jayamanne,他正在为 VS Code 开发 Python 和 Jupyter.上个月,他们 (MS) 改进了他们的 Python 扩展,以支持 Visual Code 中的 Jupyter 笔记本以及 .ipynb 导入和导出.在此处获取扩展并检查博文 如何使用使用 Jupyter 笔记本.

Ok, apparently Microsoft hired Don Jayamanne and he's working on Python and Jupyter for VS Code. And last month they (MS) improved their python extension to support Jupyter notebooks right in the Visual Code together with .ipynb import and export. Get extension here and check blog post how to use it with Jupyter notebooks.

更新二

另一个是神经元,正在开发中,但看起来不错 - 同样是 VS Code 中的笔记本,带有图表、降价等.获取它 这里

Another one is Neuron, under development, but looks nice - again, notebooks in VS Code, with graphs, markdown etc. Get it here

这篇关于Python - 如何在 Visual Studio Code 本身中显示图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆