DISTRICT 37

なにか

SeabornがJupyterに自動適用されない

Jupyterで作ったグラフを再実行したらどうもseabornが適用されていない。

原因

どうもseabornのinitに変更があったようだ。

qiita.com

公式にもちゃんと書いてある

What’s new in the package — seaborn 0.8.1 documentation

v0.8.0 (July 2017)
The default style is no longer applied when seaborn is imported. It is now necessary to explicitly call set() or one or more of set_style(), set_context(), and set_palette(). Correspondingly, the seaborn.apionly module has been deprecated.

要はset()をしなくなったとの事。このあたりのライブラリは平気で変えてくるからアップグレードをためらうんだよなぁ。

対応

set()をしなくなったのならset()をしたらいい。シンプル。これまではseabornをimportするだけで自動適用だったが、ひと手間加えることになる。でもたったの9文字。我慢しましょう。

import seaborn as sns
sns.set() #これを加える

コード

つまりset()を入れればいい

入れないとこうなる