解决方法如下:

  • 首先设置源码文件编码方式为UTF-8
  #-*- coding: utf-8 -*-
  • 接着设置字体属性字典
  font = {'family': 'SimHei',
          'color': 'black',
          'weight': 'normal',
          'size': 18,
          }
  • 在需要的地方使用,例如
  ax.set_title(u"儿童节快乐",fontdict = font)

另一种更加方便的方法是:

import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']

相关文章:

  • 2021-12-15
  • 2021-06-30
  • 2021-10-22
  • 2021-12-28
  • 2021-06-19
  • 2021-12-27
  • 2021-06-06
  • 2021-10-15
猜你喜欢
  • 2021-08-29
  • 2022-02-14
  • 2021-10-12
  • 2022-12-23
  • 2022-02-20
  • 2021-12-23
  • 2021-10-10
相关资源
相似解决方案