visual-studio - matplotlib pyplot 不在 visual studio 中绘制?

标签 visual-studio canopy

我正在使用安装了 python 工具和 canopy (python 2.7) 的 VS 2013 Express 版本。

我试图在运行代码时绘制一个简单的函数,但它不起作用:

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

plt.plot(np.random.rand(1000).cumsum())

我正在使用 IPython 的交互模式,当我在命令提示符下执行上面的命令时,我看到了绘图。

此图在 cmd 和 VS 2013 中的唯一区别是我在命令提示符下加载 IPython 时使用的 --pylab 选项。当我尝试添加 --pylab 和解释器选项时(工具 --> 设置 --> Python 工具 --> 交互式窗口)。

有人知道当我在 Visual Studio 上运行我的 python 代码时如何获得实际的 matplotlib 图吗?

感谢您的帮助。

最佳答案

你需要输入plt.show()

pylab 模式使这变得不必要。

http://matplotlib.org/faq/usage_faq.html#matplotlib-pyplot-and-pylab-how-are-they-related

关于visual-studio - matplotlib pyplot 不在 visual studio 中绘制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25919858/

相关文章:

python - "rpy2"在 Enthought Canopy 中失败(与内部 GFORTRAN 库冲突)

Enthought Canopy 中的 Matplotlib 字体

python - sklearn OMP : Error #15 ("Initializing libiomp5md.dll, but found mk2iomp5md.dll already initialized.") when fitting models

c - 链接列表未显示正确的数据

python-2.7 - Enthought Canopy 用户输入

python - 卸载 Enthought Canopy 1.5.4 时出错

visual-studio - 如何发布 Visual Studio 扩展更新?

visual-studio - 无法在企业预览版上安装 Xamarin Live 和在企业版上安装 Apple SDK

c++ - 在 Windows 应用程序的编译时嵌入 SVN 修订号

eclipse - Visual Studio + 远程 gdb 调试