여러 Visualization 테크닉 소개

https://jehyunlee.github.io/2021/03/27/Python-DS-64-kr_pop_sn/

Tex문법 사용하기

r로 시작하면서, $$으로 string을 감쌓으면 된다. Matplotlib는 자체적으로 tex문법을 rendering할 수 있다.

plt.title(r'$\\alpha > \\beta$')

Matplotlib 에서 한글 font로 출력하기

  1. 한글 폰트를 다운받고 압축을 푼다.
wget <http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip>
unzip NanumFont_TTF_ALL.zip -d NanumFont
  1. 위에서 압축을 푼 경로로 matplotlib font를 설정해준다.
import matplotlib.font_manager as fm
font_list = fm.findSystemFonts(fontpaths='/home/user/NanumFont', fontext='ttf')

print(font_list)
fontprop = fm.FontProperties(fname=font_list[3], size=10)
plt.title(tmp.columns.values[-start_idx + i], fontproperties=fontprop)

legend에 font 적용하기

이상하게 legend에는 다른방식으로 font를 적용해야한다.

import matplotlib.font_manager as fm
font_path='/home/imcomking/NanumFont'
font_name = fm.FontProperties(fname=font_path+'/NanumGothic.ttf').get_name()
plt.legend(loc=1, fontsize="xx-large", prop={'family':font_name, 'size':20})