Jupyter &IPython:%matplotlib 内联有什么作用? [英] Jupyter & IPython: What does %matplotlib inline do?
问题描述
我很好奇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
This calls code from interactiveshell.py: https://github.com/ipython/ipython/blob/aa586fd81940e557a1df54ecd0478f9d67dfb6b4/IPython/core/interactiveshell.py#L2918-L2961
这篇关于Jupyter &IPython:%matplotlib 内联有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!