반응형
참고: https://seaborn.pydata.org/tutorial/relational.html
Visualizing statistical relationships — seaborn 0.9.0 documentation
Scatter plots are highly effective, but there is no universally optimal type of visualiation. Instead, the visual representation should be adapted for the specifics of the dataset and to the question you are trying to answer with the plot. With some datase
seaborn.pydata.org
In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
In [7]:
tips = sns.load_dataset('tips')
tips.head(10)
Out[7]:
In [3]:
sns.relplot(x='total_bill', y='tip', data=tips)
Out[3]:
라벨링을 매기고싶다면 relplot의 hue변수를 이용¶
In [4]:
sns.relplot(x= 'total_bill', y='tip', hue='smoker', data=tips)
Out[4]:
라벨링과 더불어 마크유형도 바꾸고싶다면 style변수를 이용¶
In [5]:
sns.relplot(x= 'total_bill', y='tip', hue='smoker', style='smoker', data=tips)
Out[5]:
마크유형을 다른 column정보를 이용하여 변형이 가능함¶
In [6]:
sns.relplot(x= 'total_bill', y='tip', hue='smoker', style='time', data=tips)
Out[6]:
column에서 카테고리형이 아닌 변수형에도 적용이 가능¶
In [8]:
sns.relplot(x= 'total_bill', y='tip', hue='size', data=tips)
Out[8]:
hue는 카테고리를 지정하고, size변수는 변수형타입일때 표시해주는 크기를 설정해줌¶
In [9]:
sns.relplot(x= 'total_bill', y='tip', size='size', data=tips)
Out[9]:
size변수를 이용할때 원 크기를 조정이 가능함¶
In [10]:
sns.relplot(x= 'total_bill', y='tip', size='size', sizes=(15,200), data=tips)
Out[10]:
반응형
'Data > Data Visualization' 카테고리의 다른 글
[Seaborn] seaborn line plotting tutorial (1) | 2019.12.22 |
---|---|
[Seaborn] seaborn 라이브러리 연습 (0) | 2019.12.22 |