SiLaure's Data

[Seaborn] 03. barplot & countplot --막대형 그래프 본문

Records of/Learning

[Seaborn] 03. barplot & countplot --막대형 그래프

data_soin 2021. 7. 26. 10:33

 

 

- Barplot

: 어떤 데이터에 대한 값의 크기를 막대로 보여주는 plot. (a.k.a. 막대그래프)

  • 가로 / 세로 두 가지로 모두 출력 가능하다.
  • 히스토그램과는 다르다.(**)
  • 수치데이터, 범주데이터와 상관 없이 그 데이터의 수치값을 찍어준다.

 

sns.barplot(data=penguins, x='flipper_length_mm', y='species', hue='species')

출력 :

x와 y를 반대로

sns.barplot(data=penguins, x='species', y='flipper_length_mm', hue='species')

출력 :

 

 

 

- Countplot

  • 범주형 속성을 가지는 데이터들의 histogram을 보여주는 plot.
  • 종류별 count를 보여주는 방법다
  • 특정 데이터에 대해서 지표 별 개수를 나타낸다. --범주형
sns. countplot(data=penguins, x='species', hue='sex')
hue로 정보 차이 별 기준을 부여한다.
species 별로 따로 plot을 찍을 건데 정보 차이를 sex로 준다.

출력 : 

 

 

 

 

Comments