새소식

ETC/Tip - 2023.04.23

[Seaborn] Figure 하나에 Graph 여러 개 그릴 때 Legend 표시하기

  • -

plot 할 때 원하는 label을 지정

  • Legend에 표시하고 싶은 내용을 label 인자에 입력해주면 된다. 
d10_ft = check3[(check3['choice'] == 1)&(check3['decile'] == 10)]['TOTL_SQ_FT_CNT']
d1_ft = check3[(check3['choice'] == 1)&(check3['decile'] == 1)]['TOTL_SQ_FT_CNT']

f, ax = plt.subplots(1, 1)
sns.distplot(d10_ft, label = 'decile 10',ax=ax)
sns.distplot(d1_ft, label = 'decile 1',ax=ax)
ax.legend()


참고

 

How to add legend to seaborn multi-dist plot without putting the data together

I have a two series of data that i'm displaying on one seaborn histogram using the following code: import pandas import seaborn d10_ft = check3[(check3['choice'] == 1)&(check3['decile'] == 10...

stackoverflow.com

Contents

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

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