【学习笔记】python教程--数据分析--matplotlib--显示中文字符
简介
基于win10,pycharm+anaconda编译环境中,解决matplotlib绘图中中文字体显示为方框的问题
方法一:rcParams
// 设置中文字符
plt.rcParams['font.sans-serif']=['MicroSoft YaHei']
方法二:font_manager
使用font_manager,fname设置系统的中文字体路径,windows可以在【设置】–【个性化】–【字体】中找到中文字体的路径
// 设置中文字符
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname=r'C:\WINDOWS\FONTS\SIMKAI.TTF')
plt.xticks(fontproperties=my_font)