2016-06-27 6 views
4

私は、ジュピターのノートブックがどのようにプロットインラインを可能にしているのだろうかと不思議です。 githubで%matplotlib inlineを検索したところ、ソースコード(https://github.com/search?l=python&q=org%3Ajupyter+matplotlib+inline&ref=searchresults&type=Code&utf8=%E2%9C%93)が見つかりませんでした。Jupyter&IPython:%matplotlib inlineは何をしますか?

そして、ドキュメント(http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-matplotlib)では利用できません。

誰でも私に%matplotlib inlineのソースコードが表示されますか教えてください。

答えて

4

あなたがこのことから

%matplotlib?? # view source 

経由jupyterのノートブックのmatplotlibの魔法の源を見つけることができ、私たちは仕事をしている行が自己である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) 

でコードを見つけます。 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

関連する問題