matplotlib 을 사용할 때, 한글 쓰는 방법
1. 한글 글꼴 다운 받기 (영리, 비영리 목적 사용 가능한 나눔글꼴 다운로드 [https://hangeul.naver.com/2017/nanum])
- 윈도우에서 나눔글꼴 모음 설치하기를 다운 받아 실행하면 C:\windows\Fonts\ 디렉토리에 설치 됨
- 맥에서는 /Library/Fonts 나 사용자 홈 디렉토리에서 ~/Library/Fonts 에 설치
2. 가독성의 정석 나눔 고딕 예시
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import font_manager | |
font_path = 'c:/Windows/Fonts/NanumGothic.ttf' # 맥이라면 '/Library/Fonts/NanumGothic.ttf' 또는 '~/Library/Fonts/NanumGothic.ttf' | |
font_family = font_manager.FontProperties(fname=font_path).get_name() | |
plt.rcParams["font.family"] = font_family |
'노트정리 > 시각화 Visualization' 카테고리의 다른 글
matplotlib에서 축(axis)에 사용자 정의 포맷팅 적용 방법 재정리 (0) | 2024.03.03 |
---|---|
matplotlib 에서 이미지 저장(savefig) 할 때, 하단이 잘리는 문제 해결법 (0) | 2021.03.31 |
matplotlib 에서 축(axis) 내 마음대로 쓰기 (2) | 2020.04.09 |