matplotlib 中文乱码

  1. 寻找配置文件
    import matplotlib
    matplotlib.matplotlib_fname()
  1. 修改matplotlibrc文件,去掉font.family前的#
        font.family          : 支持中文的字体名
    
    • 尤其要注意这个字体名,不是字体文件的名字
    • 例如:这里的BigYoungMediumGB2.0为字体名
    • (我是同时也把字体文件的名改为了字体名(即BigYoungMediumGB2.0))
  2. 把字体文件放入到文件夹fonts tf
  3. 坐标轴的负号正常显示
    • 去掉了注释符号,同时,改为False
        axes.unicode_minus  : False
    
  4. 大功告成,换个字体感觉整个人都好了

参考链接:https://segmentfault.com/a/1190000005144275

原文地址:https://www.cnblogs.com/edhg/p/6774263.html