这是笔记,不定时更新
设置中文显示
出现以下警告:
RuntimeWarning:Glyph missing from current font. font.set_text(s,0,flags=flags)
原因:plt画图找不到字体,需要手动添加
1、使用字体管理器 font_manager
from matplotlib.font_manager import FontProperties
font=FontProperties(fname='字体文件地址',size=15)
plt.titile(u'测试测试',fontproperties=font)
2、设置中文字体
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
u'字符串前加u代表使用unicode,防止中文乱码'