【发布时间】:2017-03-06 02:49:44
【问题描述】:
我是第一次尝试 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
在谷歌搜索后我也找到了this issue on github,但我什至不知道这是否与我的情况有关(他们的大部分谈话对我来说没有意义哈哈)。
最后,我不确定这个问题是否与此相关,但为了以防万一:当我尝试通过 !vim 命令在 Jupyter 中打开 Vim 时,它出现了非常严重的故障,使我无法甚至在不完全关闭终端的情况下退出 Jupyter 本身。然而,在 IPython 控制台中调用时,Vim 工作得非常好。
我正在使用matplotlib 2.0.0。
如果有人能帮我解决这个问题,那就太好了!谢谢!
【问题讨论】:
标签: python matplotlib ipython jupyter