matplotlib에서 글꼴 설정하는 법

danbibibi·2022년 5월 14일
0

Data Analysis 🧐

목록 보기
1/1

matplotlib는 기본 글꼴이 영문 글꼴이다. 따라서 그래프에 한글을 표기하려고 하면 경고(warning)가 뜨고, 한글이 ▯으로 표시된다! 아래와 같이 rc 함수를 이용해 글꼴 설정을 바꾸어 문제를 해결할 수 있다.

import matplotlib.pyplot as plt

if os.name == 'posix':
    plt.rc("font", family="AppleGothic")

else:
    plt.rc("font", family="Malgun Gothic")
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글