본문 바로가기
Python 파이썬/seaborn

seaborn ) 한 개의 Figure에 여러 Axes 적용

by 하이방가루 2022. 3. 30.
728x90
반응형

FaceGrid()

  행과 열에 데이터 별로 상관관계를 시각화해준다.

import matplotlib.pyplot as plt
import seaborn as sns
 
# Seaborn 제공 데이터셋 가져오기
titanic = sns.load_dataset('titanic')
 
# 스타일 테마 설정 (5가지: darkgrid, whitegrid, dark, white, ticks)
sns.set_style('whitegrid')

# 조건에 따라 그리드 나누기
g = sns.FacetGrid(data=titanic, col='who', row='survived',margin_titles=True) 

# 그래프 적용하기
g = g.map(plt.hist, 'age')

pairplot()

scatter, kde, hist, reg 그래프로 데이터프레임 컬럼 간의 관계를 시각화해준다.

import matplotlib.pyplot as plt
import seaborn as sns
 
# Seaborn 제공 데이터셋 가져오기
titanic = sns.load_dataset('titanic')
 
# 스타일 테마 설정 (5가지: darkgrid, whitegrid, dark, white, ticks)
sns.set_style('whitegrid')

# titanic 데이터셋 중에서 분석 데이터 선택하기
titanic_pair = titanic[['age','pclass', 'fare']]

# 조건에 따라 그리드 나누기
g = sns.pairplot(titanic_pair)

728x90
반응형

댓글