import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
print('seaborn version : ', sns.__version__)
countplot은 seaborn의 Categorical API에서 대표적인 시각화로 범주를 이산적으로 세서 막대 그래프로 그려주는 함수입니다.
기본적으로 다음과 같은 파라미터가 있습니다. 설명에서 말하는 df는 pandas의 DataFrame을 의미합니다.
xydatahue
hue_orderpalettecolorsaturateax이 중 x, y, hue 등은 기본적으로 df의 feature를 의미합니다. dict라면 key를 의미합니다.
sns.countplot(x='race/ethnicity',data=student,
hue='gender',
order=sorted(student['race/ethnicity'].unique())
)

fig, axes = plt.subplots(1, 2, figsize=(12, 5))
sns.countplot(x='race/ethnicity',data=student,
hue='gender',
ax=axes[0]
)
sns.countplot(x='gender',data=student,
hue='race/ethnicity',
hue_order=sorted(student['race/ethnicity'].unique()),
ax=axes[1]
)
plt.show()
matplotlib과 함께 사용할 때 가장 편리하다!
