LoginSignup
6

More than 5 years have passed since last update.

Seabornが自動で適用されない

Last updated at Posted at 2018-03-11

実行環境

OS: Centos7
Python3.6 Jupyter Notebook
Seaborn 0.8.1
Matplotlib 2.0.2

実行したコード

%matplotlib inline
import numpy as np
import pandas as pd
import seabron as sns

x = np.random.normal(size=100)
titanic = sns.load_dataset('titanic')
tips = sns.load_dataset('tips')
iris = sns.load_dataset('iris')

sns.jointplot('sepal_width', 'petal_length', data=iris)

上記のコード実行結果

jointplot.png

本当はこっちになるはず

jointplot_.png

原因

seabornがimportされた際にset()が記述されてないというものでした。
seaborn0.7.1では上手く行ってたので、現行のseaborn 0.8.1とコードを比較しました。

seaborn/__init__.py
# Capture the original matplotlib rcParams$
import matplotlib as mpl
_orig_rc_params = mpl.rcParams.copy()

import seaborn objects
from .rcmod import *
from .utils import *
from .palettes import *
from .regression import *
from .categorical import *
from .distributions import *
from .timeseries import *
from .matrix import *
from .miscplot import *
from .axisgrid import *
from .widgets import *
from .xkcd_rgb import xkcd_rgb
from .crayons import crayons
from . import cm # 0.8.1のみ

set() # 0.7.1のみ
__version__ = "0.8.1"

seabornが自動で適用されない場合は__init__.pyにset()を付け加えましょう。
というか公式にちゃんと書いてました。

seaborn公式
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.
(importしてもseabornデフォルトのスタイルは適用されなくなったため、set()またはset_style(),set_context(),set_pallete()を明示的に呼び出す必要があります。)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6