spi*_*kin 9 python matplotlib ipython jupyter
我是第一次尝试Jupyter控制台,但无法让%matplotlib inline魔法发挥作用.以下是示例会话的屏幕截图:
在我运行第6行后,该图显示在一个单独的窗口中,而第7行没有做任何事情.
当我跑步时%matplotlib --list,inline作为选项之一给出:
Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'notebook', 'wx', 'qt',
'nbagg', 'agg', 'gtk', 'tk', 'ipympl', 'inline']
Run Code Online (Sandbox Code Playgroud)
当我尝试使用另一个后端时,比如说qt5,它会给出一条错误消息,因为我没有安装任何Qt.
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5, or PySide
package to be installed, but it was not found.
Run Code Online (Sandbox Code Playgroud)
运行%matplotlib??读取:
If you are using the inline matplotlib backend in the IPython Notebook
you can set which figure formats are enabled using the following::
In [1]: from IPython.display import set_matplotlib_formats
In [2]: set_matplotlib_formats('pdf', 'svg')
The default for inline figures sets `bbox_inches` to 'tight'. This can
cause discrepancies between the displayed image and the identical
image created using `savefig`. This behavior can be disabled using the
`%config` magic::
In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}
Run Code Online (Sandbox Code Playgroud)
但我不知道是否可以通过调整来解决我的问题.
当我尝试神奇的IPython控制台时,它说inline是一个Unknown Backend.
UnknownBackend: No event loop integration for u'inline'. Supported event loops are: qt,
qt4, qt5, gtk, gtk2, gtk3, tk, wx, pyglet, glut, osx
Run Code Online (Sandbox Code Playgroud)
我在谷歌搜索后也发现了这个问题,但我甚至不知道它是否与我的情况有关(他们的大多数谈话对我都没有意义).
最后,我不确定这个问题是否相关,但是在这里,以防万一:当我尝试通过!vim命令在Jupyter中打开Vim时,它会出现故障,导致我甚至无法退出Jupyter本身没有关闭终端altogther.然而,当在IPython控制台内部调用时,Vim工作得很好.
我正在使用matplotlib 2.0.0.
如果有人能帮助我解决这个问题,那就太好了!谢谢!
Imp*_*est 13
您正在运行一个完全基于文本且无法显示图像的控制台.因此,尽管inline可用,但它不会产生内联输出.
我不确定为什么它不会抛出错误,它在我的情况下会这样做:
您可以%matplotlib inline在GUI控制台中使用,例如Jupyter QTConsole
或者在浏览器中的jupyter笔记本中
| 归档时间: |
|
| 查看次数: |
14789 次 |
| 最近记录: |