Python
이차원 밀집도 그리기
이부일
2018. 11. 16. 11:07
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# seaborn 라이브러리에내장된 데이터 불러오기
tips = sns.load_dataset("tips")
# 이차원 밀집도 그리기 : 음영 효과를 넣음
ax = plt.subplot()
ax = sns.kdeplot(data = tips.total_bill,
data2 = tips.tip,
shade = True)
ax.set_title("Kernel Density Plot of Total Bill and Tip")
ax.set_xlabel("Total Bill")
ax.set_ylabel("Tip")
# 이차원 밀집도 그리기 : 음영 효과를 넣지 않음
ax = plt.subplot()
ax = sns.kdeplot(data = tips.total_bill,
data2 = tips.tip,
shade = False)
ax.set_title("Kernel Density Plot of Total Bill and Tip")
ax.set_xlabel("Total Bill")
ax.set_ylabel("Tip")
[출처] 데이터 분석을 위한 판다스 입문, Chen/Dainel Y. 지음, 김영하 옮김, 이지스퍼블리싱, p101 ~ 102