Jupyter&IPython:%matplotlib inline是什么意思?

6
1个回答

6
你可以通过以下方式在Jupyter笔记本中找到matplotlib魔术源代码:
%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 这会调用来自interactiveshell.py的代码: https://github.com/ipython/ipython/blob/aa586fd81940e557a1df54ecd0478f9d67dfb6b4/IPython/core/interactiveshell.py#L2918-L2961

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接