%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']
当我尝试使用另一个后端时,请说qt5
,因为我没有安装任何Qt,它会给出一条错误消息。
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5, or PySide
package to be installed, but it was not found.
运行%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}
但是我不知道这是我可以解决的问题。
当我尝试使用神奇的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
经过一番谷歌搜索后,我也在github上发现了这个问题,但我什至不知道这是否与我的情况有关(他们的大多数谈话对我来说都没有道理)。
最后,我不确定这个问题是否完全相关,只是为了以防万一:当我尝试通过该!vim
命令在Jupyter中打开Vim时,它的故障非常严重,甚至阻止了我退出Jupyter本身。无需完全关闭终端。但是,当在IPython控制台中调用Vim时,它工作得很好。
我正在使用matplotlib 2.0.0
。
如果有人可以帮助我解决这个问题,那就太好了!谢谢!