解决matplotlib中文无法显示问题

下载中文字体(黑体,看准系统版本)

  • 下载 SimHei 字体(或者其他的支持中文显示的字体也行)

  • 安装字体

    • linux下:拷贝字体到 usr/share/fonts 下:

      sudo cp ~/SimHei.ttf /usr/share/fonts/SimHei.ttf
      
    • windows和mac下:双击安装

  • 删除~/.matplotlib中的缓存文件

    cd ~/.matplotlib
    rm -r *
    
  • 修改配置文件matplotlibrc

    vi ~/.matplotlib/matplotlibrc
    

    将文件内容修改为:

    font.family         : sans-serif
    font.sans-serif         : SimHei
    axes.unicode_minus  : False 

猜你喜欢

转载自www.cnblogs.com/ForPython/p/9247044.html
今日推荐