Back to feed
Renewal·마흔의 생활코딩

(Encoding Test) Broken Korean Fonts in matplotlib

NS
normalstory
cover image

matplotlib's font defaults to 'sans-erif', so Korean characters may come out garbled. 

Check the font

import matplotlib
matplotlib.rcParams['font.family']

 

for Win

# 한글 깨짐 개선 
import matplotlib
import matplotlib.font_manager as fm

font_name = fm.FontProperties(fname = 'C:/Windows/Fonts/malgun.ttf').get_name()
matplotlib.rc('font', family = font_name)
matplotlib.rcParams['axes.unicode_minus'] = False

 

for Mac

# 한글 깨짐 개선 
import matplotlib.pyplot as plt
from matplotlib import rc 

rc('font', family='AppleGothic') 			
plt.rcParams['axes.unicode_minus'] = False  

 

 

 

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Why You Should Use .html Instead of .md Seeing Is Believing

Jul 25, 2026·1 min
Renewal

The Most Important Thing About AX

Jul 17, 2026·2 min
Renewal

디지털 기술과 혁신에 대한 논고(지탱하는 힘)

Jul 17, 2026·5 min