matplotlib 이용해서 라벨별 이미지를 확인하려고 했더니 라벨이 한글로 되어있어서 폰트 깨짐 현상이 있었다.
검색해 보니 나눔고딕 등의 폰트를 이용하면 깨짐 현상이 없어진다고 해서 폰트를 설치해 주었다.
윈도우에 설치된 리눅스를 이용하고 있지만, 당연하게도 윈도우에 폰트를 설치한다고 리눅스에 자동으로 적용되지는 않아서 리눅스에 나눔고딕 폰트를 설치하고 적용하는 방법을 찾아보았다.
apt install fonts-nanum-coding 패키지 설치하기
apt install을 이용하여 글꼴을 설치한다.
apt install fonts-nanum-coding
설치 확인
ls /usr/share/fonts/truetype/nanum
NanumGothicCoding-Bold.ttf NanumGothicCoding.ttf 이 출력되면 설치 완료.
matplotlib 글꼴 설정
font_path = '/usr/share/fonts/truetype/nanum/NanumGothicCoding.ttf'
bold_font_path = '/usr/share/fonts/truetype/nanum/NanumGothicCoding-Bold.ttf'
matplotlib.font_manager.fontManager.addfont(font_path)
matplotlib.font_manager.fontManager.addfont(bold_font_path)
plt.rcParams['font.family'] = 'NanumGothicCoding'
NanumGothicCoding.ttf 만 설정해주면
findfont: Font family 'NanumGothicCoding-Bold' not found.
에러가 발생하기 때문에 NanumGothicCoding-Bold 까지 설정해줘야 한다.
'IT' 카테고리의 다른 글
[Streamlit] 스트림릿이란? 데이터분석 시각화 오픈소스 라이브러리 (0) | 2023.05.31 |
---|---|
Pyspark를 위한 Java 설치 및 JAVA_HOME 환경변수 설정 (0) | 2023.05.24 |
[Spark] JupyterLab에 pyspark kernel 설치 No module named pyspark_kernel.install 해결 (0) | 2023.05.13 |
[Database] Oracle db 삭제 uninstall deinstall 하는 법 (0) | 2023.05.06 |
데이콘 일기 (1) - 이미지 분류 경진대회 준비하기 (0) | 2023.04.29 |
댓글