matplotlib python 内联开/关 [英] matplotlib python inline on/off

查看:31
本文介绍了matplotlib python 内联开/关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我启动带有内联 matplotlib 的 ipython 笔记本,有没有办法随后绘制图形,使其以标准"非内联方式显示,而无需在没有内联命令的情况下重新加载笔记本?我希望能够在笔记本中嵌入一些图形,但在传统的交互模式中可以嵌入其他图形,我可以在其中进行缩放和平移.

If I start an ipython notebook with matplotlib inlined, is there a way to subsequently plot a figure so that it shows in the "standard", non-inlined, way, without having to reload the notebook without the inline command? I'd like to be able to have some figures inlined int he notebook, but others in the traditional interactive mode, where I can zoom and pan.

推荐答案

可以通过%matplotlib 切换matplotlib的后端.要切换回系统的默认后端,请使用 %matplotlib auto 或仅使用 %matplotlib.

You can switch the matplotlib's backend by %matplotlib <backend>. To switch back to your system's default backend use %matplotlib auto or just simply %matplotlib.

有很多后端可用,例如gtkqtnotebook 等.我个人强烈推荐notebook(又名 nbagg)后端.它类似于 inline,但具有交互性,允许从 Jupyter 内部进行缩放/平移.

There are many backends available such as gtk, qt, notebook, etc. I personally highly recommend the notebook (a.k.a. nbagg) backend. It is similar to inline but interactive, allowing zooming/panning from inside Jupyter.

有关更多信息,请尝试:?%matplotlib 在 IPython/Jupyter 或 IPython 的在线文档

For more info try: ?%matplotlib inside an IPython/Jupyter or IPython's online documentation

这篇关于matplotlib python 内联开/关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆