새소식

ETC/Tip - 2023.01.14

[Seaborn] scatterplot에 regression line 추가하기

  • -

regplot과 scatterplot 함께 활용하기

  • regplot의 점이 노출되지 않게 하려면 scatter = False로 설정해야 한다.
fig, axs = plt.subplots(2, 1, figsize = (15, 10))

sns.regplot(data = test_final, x = "test_loss", y = "val_loss", scatter = False, ax = axs[0])
sns.scatterplot(data = test_final, x = "test_loss", y = "val_loss", hue = "test_pearsonr", ax = axs[0])
sns.regplot(data = test_final, x = "test_loss", y = "val_loss", scatter = False, ax = axs[1])
sns.scatterplot(data = test_final, x = "test_loss", y = "val_loss", hue = "test_f1_score", ax = axs[1])

FacetGrid 활용하기

  • 아래 링크를 참고하면 된다.
 

Scatterplot with point colors representing a continuous variable in seaborn FacetGrid

I am trying to generate multi-panel figure using seaborn in python and I want the color of the points in my multi-panel figure to be specified by a continuous variable. Here's an example of what I am

stackoverflow.com

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.