背景、疑問
ただいまjupyterで機械学習についてオンラインコースで勉強しているところなのですが、そこで%matplotlib inline
しないとcell内にグラフが表示されないよ、と教えられました。
がしかし、%matplotlib inline
コマンド実行しなくてもcell内にグラフが表示されるので、なぜかと思ってちょっと調べてみました。
原因まとめ
もともとは%matplotlib inline
する必要があったようです。
しかし、あるときからデフォルトでinlineがオンになるように修正されたようです。
コミットログとGitHubのリリースタブからipykernel 4.4.0からはinlineがデフォルトでオンになっているようです。
コミットログ
コミットログを見ると2016/07/13にコミットされた変更のようです。
$ git clone https://github.com/docker/doodle.git
$ cd ipykernel/
$ git log -1 70e096805778cb79eb1729f5bb2f9ddebf85e001
commit 70e096805778cb79eb1729f5bb2f9ddebf85e001
Author: Benjamin Ragan-Kelley <benjaminrk@gmail.com>
Date: Wed Jul 13 19:54:24 2016 -0500
Make inline the default matplotlib backend
uses MPLBACKEND env (matplotlib > 1.5).
Trigger extra IPython inline setup when inline backend is loaded.
We can't call the simpler `ip.enable_matplotlib()` here because
this will be triggered during pyplot import,
and enable_matplotlib() imports pyplot which isn't ready yet.
GitHubのReleasesタブ
そしてその変更がどのバージョンで取り込まれたのかをGitHubのreleasesタブで見てみると4.4.0から含まれているようです。
https://github.com/ipython/ipykernel/releases?after=4.4.1
その他
GitHubにissueもあがっていました。(反映されていないようで、まだOpenのままですが・・・)
https://github.com/ipython/ipython/issues/6424