matplotlib中文显示乱码原因:
matplotlib默认不支持中文字符,而默认的英文字体无法显示中文。
解决方式一:
用font_manager处理,可以指定你想要的字体:
1.导入font_manage
2.返回字体
3.只要有用到中文字符的地方都要加入字体参数font_properties,如刻度有用到中文,就要加此参数;在标题有用到中文,也要加此参数…
例子:
import matplotlib.pyplot as plt
from matplotlib import font_manager
myfont = font_manager.FontProperties(fname = "字体文件路径")
plt