본문 바로가기
CS

ubuntu matplotlib 한글 폰트 설정

by judy@ 2023. 5. 19.

폰트 설치

$ sudo apt-get update
$ sudo apt-get install fonts-nanum*

캐시 삭제

$ sudo fc-cache -fv

설치된 폰트 확인

$ ls /usr/share/fonts/truetype/nanum
NanumBarunGothic.ttf            NanumGothicEco.ttf             NanumPen.ttf
NanumBarunGothicBold.ttf        NanumGothicEcoBold.ttf         NanumSquareB.ttf
NanumBarunGothicLight.ttf       NanumGothicEcoExtraBold.ttf    NanumSquareEB.ttf
NanumBarunGothicUltraLight.ttf  NanumGothicExtraBold.ttf       NanumSquareL.ttf
NanumBarunpenB.ttf              NanumGothicLight.ttf           NanumSquareR.ttf
NanumBarunpenR.ttf              NanumMyeongjo.ttf              NanumSquareRoundB.ttf
NanumBrush.ttf                  NanumMyeongjoBold.ttf          NanumSquareRoundEB.ttf
NanumGothic.ttf                 NanumMyeongjoEco.ttf           NanumSquareRoundL.ttf
NanumGothicBold.ttf             NanumMyeongjoEcoBold.ttf       NanumSquareRoundR.ttf
NanumGothicCoding-Bold.ttf      NanumMyeongjoEcoExtraBold.ttf
NanumGothicCoding.ttf           NanumMyeongjoExtraBold.ttf

파이썬에서 확인

import matplotlib.font_manager
[f.fname for f in matplotlib.font_manager.fontManager.ttflist]

위에서 설치된 폰트를 설정

plt.rcParams["font.family"] = 'NanumGothic'

 

++ 마이너스 폰트 설정

import matplotlib
matplotlib.rcParams['axes.unicode_minus'] = False

 

참고 자료

https://hooni-playground.com/961/

 

 

반응형