Matplotlib - (displot())

category
URL
date
Jan 27, 2023
slug
Matplotlib-displot
author
status
Public
tags
Playdata_Python
summary
Matplotlib - displot
type
Post
thumbnail
updatedAt
Jan 27, 2023 08:08 AM

displot() col로 그래프 나누기

  • displot()은 col키워드 인수를 활용하여 subset을 한번 더 분류
sns.displot(data = penguins, x="flipper_length_mm", hue="species",col="sex",kind="kde")
notion image

displot() 그래프 크기 설정

  • height와 aspect를 활용해서 그래프 크기 제어
  • height의 단위는 inches이며 aspect는 height와 aspect값을 곱해서 얻음
# displot() 그래프 크기 설정
sns.displot(
    data = penguins, y="flipper_length_mm", hue="sex", col="species",
    kind = "ecdf", height = 4, aspect = .7,
)
notion image
 

displot() col로 그래프 나누기

  • 각 axis label과 title도 지정 가능
  • axis label은 set_axis_labels(xlabel, ylabel) 메서드를. title은 set_titles()을 활용하는데, fromatting keys인 {col_var}와 {col_name}을 조합해서 포맷팅 가능
# displot() col로 그래프 나누기
g = sns.displot(
    data = penguins, y="flipper_length_mm", hue="sex", col="species",
    kind = "kde", height = 4, aspect = .7,
)

g.set_axis_labels("Density (a.u.)", "Flipper length (mm)")
g.set_titles("{col_name} penguins")
notion image