Matplotlib:显示中文、设置描述信息

数据表显示中文

matplotlib默认字体不显示中文(中文显示为方框)。

故需要对其设置字体

修改matplotlib字体的方法:

  • 通过matplotlib.rc修改
  • mac系统下可以通过matplotlib下的font manager修改

matplotlib.rc(‘font’,**fontDict)

# 设置数据表字体为微软雅黑,便于中文显示
matFont = {
    
    
    'family':'Microsoft YaHei', # 字体
    'weight':'bold',            # 粗细
    'size'  :6                  # 大小
}
matplotlib.rc('font',**matFont)

设置轴的描述信息

  • 表的标题:plt.title(‘内容’)
  • x轴注释:plt.xlabel(‘内容’)
  • y轴注释:plt.ylabel(‘内容’)

猜你喜欢

转载自blog.csdn.net/Dae_Lzh/article/details/118878885