필요 라이브러리 import
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
#배경스타일 지정
sns.set(style="darkgrid")
데이터셋 로드 및 조회
tips = sns.load_dataset("tips")
tips
total_bill | tip | sex | smoker | day | time | size | |
---|---|---|---|---|---|---|---|
0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
3 | 23.68 | 3.31 | Male | No | Sun | Dinner | 2 |
4 | 24.59 | 3.61 | Female | No | Sun | Dinner | 4 |
... | ... | ... | ... | ... | ... | ... | ... |
239 | 29.03 | 5.92 | Male | No | Sat | Dinner | 3 |
240 | 27.18 | 2.00 | Female | Yes | Sat | Dinner | 2 |
241 | 22.67 | 2.00 | Male | Yes | Sat | Dinner | 2 |
242 | 17.82 | 1.75 | Male | No | Sat | Dinner | 2 |
243 | 18.78 | 3.00 | Female | No | Thur | Dinner | 2 |
244 rows × 7 columns
sns.relplot(x="total_bill", y="tip", data=tips)
<seaborn.axisgrid.FacetGrid at 0x1c6133009b0>
hue : marker의 색상으로 구분
sns.relplot(x="total_bill", y="tip", hue="smoker", data=tips)
<seaborn.axisgrid.FacetGrid at 0x1c61360a630>
style : marker의 모양 구분
sns.relplot(x="total_bill", y="tip", hue="smoker", style="time", data=tips)
<seaborn.axisgrid.FacetGrid at 0x1c61360aeb8>
palette : marker 색상 변경 (색상표)
sns.relplot(x="total_bill", y="tip", hue="size", palette="jet", data=tips)
<seaborn.axisgrid.FacetGrid at 0x1c6146f2860>
size : marker의 size 변경
sizes : size 범위
sns.relplot(x="total_bill", y="tip", size="size", sizes=(15, 200), data=tips)
<seaborn.axisgrid.FacetGrid at 0x1c6147ca860>