LoginSignup
12
12

More than 5 years have passed since last update.

seaborn setメソッドの使い方まとめ

Posted at

前書き

データ視覚化ライブラリのseabornにはsetメソッドというものがあり、それを使うと簡単にプロットのデザインが変更できます。今回はsetのなかのstylepalettの使い方をまとめました。

styleはチャートの背景のグリッドの有無や色、palettはチャート自体の色合いを調整します。

seaborn.setのより詳細な情報はこちら(seaborn公式サイト)

視覚化をするデータの作成


import pandas as pd
import numpy as np

df = pd.DataFrame({'a': np.random.randn(100),
                   'b': np.random.randn(100),
                   'c': np.random.randn(100),
                 'target':np.random.randint(2, size=100)})

df.head()

スクリーンショット-2018-09-22-13.58.41.png

style

darkgrid

import seaborn as sns
sns.set(style='darkgrid')
sns.scatterplot(x='a', y='b', hue='target', data=df)

download-2.png

whitegrid


import seaborn as sns
sns.set(style='whitegrid')
sns.scatterplot(x='a', y='b', hue='target', data=df)

download-3.png

dark


import seaborn as sns
sns.set(style='dark')
sns.scatterplot(x='a', y='b', hue='target', data=df)

download-4.png

white


import seaborn as sns
sns.set(style='white')
sns.scatterplot(x='a', y='b', hue='target', data=df)

download-5.png

palette

deep


import seaborn as sns
sns.set(palette='deep')
sns.boxplot(x='target', y='b', data=df)

download-8.png

muted


import seaborn as sns
sns.set(palette='muted')
sns.boxplot(x='target', y='b', data=df)

download-1-1.png

pastel

import seaborn as sns
sns.set(palette='pastel')
sns.boxplot(x='target', y='b', data=df)

download-9.png

bright


import seaborn as sns
sns.set(palette='bright')
sns.boxplot(x='target', y='b', data=df)

download-2-1.png

dark

import seaborn as sns
sns.set(palette='dark')
sns.boxplot(x='target', y='b', data=df)

download-3-1.png

colorblind


import seaborn as sns
sns.set(palette='colorblind')
sns.boxplot(x='target', y='b', data=df)

download-5-1.png

12
12
0

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
12
12