Tech for good

[Colab] 구글 코랩 한글 폰트 깨짐 문제 해결하는 방법 본문

IT/Data Science

[Colab] 구글 코랩 한글 폰트 깨짐 문제 해결하는 방법

Diana Kang 2021. 6. 1. 11:02
# 한글로 그래프 제목 입력해도 글씨 깨지지 않게 함

!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf

위 코드 입력 후 런타임 다시 시작 하고 위 코드 제외한 다른 코드 실행하면서 진행

 

# 폰트 지정

import matplotlib.pyplot as plt

plt.rc('font', family='NanumBarunGothic') 

+ plt.rc에서의 rc 의미: Each time Matplotlib loads, it defines a 'runtime configuration (rc)' containing the default styles for every plot element you create. This configuration can be adjusted at any time using the plt. rc convenience routine.