Matplotlib - jointplot
category
URL
date
Jan 27, 2023
slug
Matplotlib-jointplot
author
status
Public
tags
Playdata_Python
summary
Matplotlib - jointplot
type
Post
thumbnail
updatedAt
Jan 27, 2023 08:20 AM
jointplot
- 두 개의 변수의 분포를 나타낼 때 활용하면 좋은 플롯
- histogram과 scatter plot을 동시에 사용해서 시각적 효과를 ㅍ ㅛ현
- data 키워드 인수로 penguins의 DataFrame을 전달
- x에는 DataFrame의 column name인 bill_length_mm, y에는 DataFrame의 column name인 bill_depth_mm을 전달
- histplot()과 scatterplot()을 동시에 사용해서 데이터의 분포를 더 자세하고 직관적으로 파악해 볼 수 있지만 특징을 찾기 어렵다.
# jointplot
penguins = sns.load_dataset("penguins")
sns.jointplot(data=penguins, x="bill_length_mm", y = "bill_depth_mm")

1.hue 키워드
# hue 키워드 인수
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")

2.kind 키워드
# kind 키워드
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species",kind="kde")

3.kind 키워드 인수에 reg값을 전달해서 선형 회귀에 대한 결과를 그래프로 바로 볼 수 있음.
- hue와 kind=’reg’는 동시에 사용 할 수 없는 옵션
# kind 키워드 인수에 reg값을 전달
adelie_penguins = penguins[penguins["species"] == "Adelie"]
sns.jointplot(data=adelie_penguins, x="bill_length_mm", y="bill_depth_mm",kind="reg")

4.height,ratio,marginal_ticks 키워드 인수 추가
- 전체 그래프의 크기(height), main과 marginal 그래프 간의 비율(ratio), marginal histogram에 ticks을 표현할지 조절 가능
# height, ratio,marginal_ticks
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species",
height=7, ratio=2, marginal_ticks=True)
