Python

관계 그래프 그리기

이부일 2018. 11. 16. 11:35

import numpy as np

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline


# seaborn 라이브러리에내장된 데이터 불러오기
tips = sns.load_dataset("tips")


# 관계 그래프 그리기
# 산점행렬도의 upper triangular matrix에 산점도와 회귀직선
# 산점행렬도의 lower triangular matrix에 이차원 밀집도
# 산점행렬도의 diagonal matrix에 히스토그램
pair_grid = sns.PairGrid(tips)
pair_grid = pair_grid.map_upper(sns.regplot)
pair_grid = pair_grid.map_lower(sns.kdeplot, shade = True)
pair_grid = pair_grid.map_diag(sns.distplot, rug = True)
plt.show()

자동 대체 텍스트를 사용할 수 없습니다.


[출처] 데이터 분석을 위한 판다스 입문, Chen/Dainel Y. 지음, 김영하 옮김, 이지스퍼블리싱, p105