我想在一个文件夹中有一个带有python
脚本的批处理文件。批处理文件应该调用IPython
中的脚本,并以内联/嵌入式方式绘制图形。虽然有很多关于这方面的信息,但我没能让它发挥作用。
IPython
运行python
脚本,显示嵌入的绘图?pylab
还是只需在脚本中导入matplotlib.pyplot
?%pylab inline
/%matplotlib inline
?后一个命令给出
In [1]: %pylab inline
UsageError: Invalid GUI request u'inline', valid ones are:[None, 'osx', 'qt4',
'glut', 'gtk3', 'pyglet', 'wx', 'none', 'qt', 'gtk', 'tk']
In [2]: %matplotlib inline
UsageError: Invalid GUI request u'inline', valid ones are: [None, 'osx', 'qt4',
'glut', 'gtk3', 'pyglet', 'wx', 'none', 'qt', 'gtk', 'tk']`
到目前为止,我试着做了以下事情(不走运)
ipython --pylab=inline example_plots.py
给我下面的,然后退出
E:\CD\package\bin>ipython --pylab=inline example_plots.py
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
或者从控制台运行,但像往常一样弹出数字(并立即关闭):
E:\CD\package\bin>ipython --pylab=inline example_plots.py
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
WARNING: 'inline' not available as pylab backend, using 'auto' instead.
Using matplotlib backend: Qt4Agg
# runs python script as usual (not inline)
跟随How to make IPython notebook matplotlib plot inline
对于批处理文件(与控制台相同):
ipython notebook --pylab inline example_plots.py
2014-01-26 17:52:10.101 [NotebookApp] Using existing profile dir: u'C:\\Users\\Robert\\.ipython\\profile_default'
2014-01-26 17:52:10.111 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-01-26 17:52:10.127 [NotebookApp] Serving notebooks from local directory: E:\CD\package\bin
2014-01-26 17:52:10.128 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
2014-01-26 17:52:10.128 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
打开一个空笔记本,就这样。
我还应该尝试什么?
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
IPython 1.1.0 -- An enhanced Interactive Python.
格雷格在这里回答:
Start ipython qtconsole as interactive interpreter after script execution
它使用
-m
标志工作或者
但我不知道,这两个选项
pylab inline
和matplotlib inline
之间的区别是什么。根据hereI图,我宁愿使用--matplotlib inline
即使添加文件以结束它也可以做我想做的事情,但它会在执行后抱怨
unknown failure
。pyplot.show(block=True)
也会给予和unknown failure
如何使用IPython运行python脚本,显示嵌入的绘图?
ipython qtconsole <yourscript.py>
。jupyter qtconsole <yourscript.py>
我需要使用pylab还是只需在脚本中导入matplotlib.pyplot?
%matplotlib inline
。是否要使用%pylab inline/%matplotlib inline?
%matplotlib inline
。相关问题 更多 >
编程相关推荐