반응형
In [12]:
import seaborn as sns
import pandas as pd
import numpy as np
In [2]:
sns.__version__
Out[2]:
In [3]:
sns.set()
sns.set_style('whitegrid')
sns.set_color_codes()
In [4]:
current_palette = sns.color_palette()
sns.palplot(current_palette)
In [5]:
tips = sns.load_dataset("tips")
In [17]:
tips.head(10)
Out[17]:
relplot¶
In [8]:
sns.relplot(x='total_bill', y = 'tip', hue = 'smoker', style = 'smoker', data=tips)
Out[8]:
In [15]:
df = pd.DataFrame(dict(time=np.arange(500), value=np.random.randn(500).cumsum()))
g = sns.relplot(x='time', y='value', kind= 'line', data=df)
g.fig.autofmt_xdate()
catplot¶
In [16]:
sns.catplot(x='day', y='total_bill', hue='smoker',
col='time', aspect=.6,
kind = 'swarm', data = tips)
Out[16]:
In [19]:
titanic = sns.load_dataset('titanic')
g = sns.catplot(x='fare', y='survived', row='class', kind='box', orient='h', height=1.5, aspect=4,
data=titanic.query('fare > 0'))
g.set(xscale='log');
pairplot¶
In [21]:
iris = sns.load_dataset('iris')
sns.pairplot(iris, hue = 'species')
Out[21]:
In [22]:
sns.pairplot(iris, hue='species', palette='husl')
Out[22]:
In [23]:
sns.pairplot(iris, vars=['sepal_width', 'sepal_length'])
Out[23]:
Heatmap¶
In [27]:
from matplotlib import pyplot as plt
flights = sns.load_dataset('flights')
flights = flights.pivot('month', 'year', 'passengers')
plt.figure(figsize=(15, 15))
ax = sns.heatmap(flights, annot=True, fmt='d')
반응형
'Data > Data Visualization' 카테고리의 다른 글
[Seaborn] seaborn line plotting tutorial (1) | 2019.12.22 |
---|---|
[Seaborn] seaborn scatter tutorial (0) | 2019.12.22 |