pbj0812의 코딩 일기

[PYTHON] displot, histplot 크기 조정하기 본문

ComputerLanguage_Program/PYTHON

[PYTHON] displot, histplot 크기 조정하기

pbj0812 2021. 6. 18. 00:06

0. 목표 

 - displot, histplot 크기 조정하기

1. 실습

 1) library 호출

   - figure size 미리 조정

   * seaborn version update 필요 : pip install seaborn==0.11.1

import matplotlib.pyplot as plt
import seaborn as sns
sns.set(rc={'figure.figsize':(15, 5)})
import pandas as pd

 2) iris 데이터셋 로드

df = sns.load_dataset('iris')

 3) distplot

  - 없어질거라고 한다.

sns.distplot(df['sepal_length'])

 4) histplot

  - 크기가 잘 맞춰 나온다.

sns.histplot(df['sepal_length'])

 5) displot

  - 그림 크기가 마음대로 안 됨.

sns.displot(df['sepal_length'])

  - Figure-level(displot), axes-level(histplot) 함수간의 차이로 인하여 그렇다고 함.

공식문서 제공 그림

  - displot 에서는 아래와 같이 옵션을 사용하여 크기 조정 가능

  - height : 높이, aspect * height = width

sns.displot(df['sepal_length'], height = 5, aspect = 3)

2. 참고 

 - seaborn.distplot

 - Overview of seaborn plotting functions

 - seaborn.displot

Comments