Sunday, December 7, 2025

Display CJK fonts in matplotlib

Error: Glyph 21518 (\N{CJK UNIFIED IDEOGRAPH-540E}) missing from font(s) DejaVu Sans 

使用matplotlib绘图中文字符显示问题:UserWarning: missing from current font

Code added:

from pylab import mpl
mpl.rcParams["font.sans-serif"] = ["SimSong"]

# all_rcParams_keys = mpl.rcParams.keys()
# You can then iterate through them or convert to a list
# for key in all_rcParams_keys:
#    print(key)

 

Blog Archive

Followers