Python, matplotlib 한글 깨짐 (Windows)

 

정리. 수알치 오상문

 

간단하게 정리하면, 

1. 나눔 글꼴 설치한다.
2. matplotlib 설정 파일에 사용할 글꼴을 설정한다.

 

나눔글꼴을 찾아서 다운로드하고 압축을 풀어서 C:\Windows\Fonts 경로에 저장합니다.

(Windows 버전에 맞는 글꼴 저장 위치 확인하세요.)

 

NanumFontSetup_TTF_GOTHIC.zip
7.57MB

 

이제 matplotlib 설치 경로 하위의 mpl-data 경로로 이동합니다.

(예;  C:\Users\...\AppData\Local\Programs\Python\Python39\Lib\site-packages\matplotlib\mpl-data)

 

matplotlibrc 파일을 메모장이나 에디터에서 엽니다. 

아래 위치를 찾아서 사용할 글꼴 이름을 'Malgun Gothic'으로 설정하고 저장합니다.

-------------------------------------------------------------------------------------

## Note that font.size controls default text sizes.  To configure
## special text sizes tick labels, axes, labels, title, etc., see the rc
## settings for axes and ticks.  Special text sizes can be defined
## relative to font.size, using the following values: xx-small, x-small,
## small, medium, large, x-large, xx-large, larger, or smaller
## font.family: sans-serif

#font.family:  Malgun Gothic
#font.style:   normal
#font.variant: normal
#font.weight:  normal
#font.stretch: normal
#font.size:    10.0

-------------------------------------------------------------------------------------------

 

이제 여러분의 matplotlib 코드를 실행하면, 아래 예시 화면처럼 그래프에 한글이 출력될 것입니다. 

 

 

[참조] https://operstu1.tistory.com/80

 

<Python matplotlib> matplotlib 한글 폰트 깨짐 수정[진짜 되는 수정] 따라만 하세요

1. 오류의 형태 2. 해결 과정 3. 해결 방법 [바로 해결 방법으로 가실 분은 해결방법을 눌러 이동하세요] 파이썬과 matplotlib 등 모든 언어와 라이브러리가 영어를 주 언어로 사용하다보니 한글 사용

operstu1.tistory.com

 

반응형

+ Recent posts