페이지

2023년 1월 17일 화요일

Matplotlib에서 한글 표시 (Ubuntu + Anaconda)

Matplotlib에서 한글 표시 (Ubuntu + Anaconda)

한글 폰트 설치 및 사용

Matplotlib로 그린 그래프에서 한글이 제대로 표시되지 않을 때 나눔 글꼴 폰트를 설치하고 사용해 보시기 바랍니다.

1. 나눔 글꼴 설치하고 캐시 삭제

$ sudo apt-get install fonts-nanum*
$ sudo fc-cache -fv

2. 나눔 글꼴 설치 확인

$ ls -l /usr/share/fonts/truetype/nanum/

3. Matplotlib에 나눔 글꼴 복사하고 캐시 삭제

$ sudo cp /usr/share/fonts/truetype/nanum/Nanum* ~/anaconda3/lib/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf/
$ rm -rf ~/.cache/matplotlib/*

4. Matplotlib에서 폰트 지정

import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'NanumGothic'
# 축의 레이블 표시에서 '-' 기호가 깨지는 문제 해결
plt.rcParams['axes.unicode_minus'] = False

참고 자료

Written with StackEdit.

댓글 없음:

댓글 쓰기

유전자 정보에 따라 단백질이 생성되는 과정

  유전 정보는 DNA에 저장되어 있으며, 이 정보는 전사(transcription) 과정을 통해 RNA로 옮겨지고, 번역(translation) 과정을 통해 단백질로 만들어집니다. 진핵생물(사람을 포함한 대부분의 고등 생물)의 유전자는 단백질 정보를...