jupyter matplot 한글 폰트 설정

몇 번 헤매다 답을 찾았다.

https://stackoverflow.com/questions/42097053/matplotlib-cannot-find-basic-fonts

I had this exact same problem on a Vagrant VM running Ubuntu Xenial 64-bit. No matter how many fonts I had already installed, matplotlib was having a problem with the “system” font name “sans-serif”. I fixed it by:

  • Stopping Jupyter
  • Installing font-manager: sudo apt install font-manager
  • Cleaning the matplotlib cache directory: rm ~/.cache/matplotlib -fr
  • Restarting Jupyter.

No more error messages about sans-serif.

해당 코드에 아래 두 줄을 삽입한다. 폰트는 찾아서 해당 위치에 넣어 준다.

font_name = font_manager.FontProperties(fname="/usr/share/fonts/truetype/nanum/NanumGothic.ttf").get_name()
rc('font', family=font_name)

코멘트

댓글 남기기

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.