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

Steadily, for the long haul, without burning out

Mar 31, 2026·9 min
Renewal

Tech-life balance

Feb 7, 2026·3 min
Renewal

Humanality, by Park Jeong-ryeol

Feb 7, 2026·11 min