[python]打日语

#-*-coding:utf-8-*-
import matplotlib.font_manager as fm
fonts = fm.findSystemFonts()
i=0
print(fonts)
print("")
for f in fonts:
    font = fm.FontProperties(fname=f)
    print(i)
    print(fonts[i])
    print(font.get_name())
    i = i+ 1
#input(">")

这可以看看系统里支持哪些字体,然后我的系统里有明朝

114
/System/Library/Fonts/ヒラギノ明朝 ProN.ttc
Hiragino Mincho ProN

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(16, 8))
plt.rcParams["font.family"] = "Hiragino Mincho ProN"
plt.plot(x,y)
plt.title(titlename)
#titlename里有日语

你可能感兴趣的:(python)