[python] matplotlib로 plot 그릴 때 한글 깨짐 문제

Chan·2022년 8월 25일
0
  • matplotlib는 python에서 데이터 시각화를 할 때 주로 사용하는 라이브러리 입니다. 특히 pandas나 numpy를 사용할 때 유용합니다.

<한글깨짐 문제>

  • 계기 : matplotlib의 pyplot를 사용해서 그래프를 그리던 도중 발생

  • 해결 방법 :
    아래와같이 matplotlib의 font_manager와 rc를 이용해서 컴퓨터 내부에 있는 한글 폰트를 사용해서 해결
from matplotlib import font_manager, rc

path = 'C:/Windows/Fonts/malgun.ttf'
font_name = font_manager.FontProperties(fname=path).get_name()
rc('font', family=font_name)
profile
호기심에 그때그때 궁금한거 기록하는 곳

0개의 댓글