matplotlib显示中文问题

发布时间 2023-12-14 15:26:19作者: 王冰冰

引用自:https://zhuanlan.zhihu.com/p/104081310

查看支持的字体:

# 查询当前系统所有字体
from matplotlib.font_manager import FontManager
mpl_fonts = set(f.name for f in FontManager().ttflist)
print('all font list get from matplotlib.font_manager:')
for t in sorted(mpl_fonts):
    print(t)

设置字体

plt.rc("font",family='YouYuan')

linux下需要拷贝中文字体到

~/miniconda3/envs/main/lib/python3.8/site-packages/matplotlib/mpl-data/matplotlibrc

https://blog.csdn.net/ninjaxuxu/article/details/88685023