Jupyter &IPython:%matplotlib 内联有什么作用? [英] Jupyter & IPython: What does %matplotlib inline do?

查看:42
本文介绍了Jupyter &IPython:%matplotlib 内联有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇jupyter笔记本如何在线启用绘图.我在 github 中搜索了 %matplotlib inline 并没有找到源代码(

I'm curious that how jupyter notebook enables the plot inline. I searched %matplotlib inline in github and didn't find the source code (https://github.com/search?l=python&q=org%3Ajupyter+matplotlib+inline&ref=searchresults&type=Code&utf8=%E2%9C%93).

它在文档中不可用(http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-matplotlib ).

And it is not avaiable in the docs (http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-matplotlib).

谁能告诉我在哪里可以看到%matplotlib内联的源代码?

Could anyone tell me where can I see the source code of %matplotlib inline?

推荐答案

您可以通过

%matplotlib?? # view source

由此我们找到python3.5/site-packages/IPython/core/magics/pylab.py

    args = magic_arguments.parse_argstring(self.matplotlib, line)
    if args.list:
        backends_list = list(backends.keys())
        print("Available matplotlib backends: %s" % backends_list)
    else:
        gui, backend = self.shell.enable_matplotlib(args.gui)
        self._show_matplotlib_backend(args.gui, backend)

正在执行工作的行是self.shell.enable_matplotlib.您可以在 IPython github 存储库中找到它:https://github.com/ipython/ipython/blob/aa586fd81940e557a1df54ecd0478f9d67dfb6b4/IPython/core/magics/pylab.py#L100

The line that is doing the work is self.shell.enable_matplotlib. You can find this in the IPython github repository: https://github.com/ipython/ipython/blob/aa586fd81940e557a1df54ecd0478f9d67dfb6b4/IPython/core/magics/pylab.py#L100

这从interactiveshell.py调用代码:

This calls code from interactiveshell.py: https://github.com/ipython/ipython/blob/aa586fd81940e557a1df54ecd0478f9d67dfb6b4/IPython/core/interactiveshell.py#L2918-L2961

这篇关于Jupyter &IPython:%matplotlib 内联有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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