Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@takeshiD

Seabornが自動で適用されない

More than 3 years have passed since last update.

実行環境

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()を明示的に呼び出す必要があります。)

7
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
takeshiD
肉すき!(*^○^*)

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?