zoukankan      html  css  js  c++  java
  • matplotlib中文显示的问题

    原因

    这是因为matplotlib库不是国人写的,作者写的时候并没有考虑那么多的语言显示

    解决思路

    手动安装字体

    第1步 安装字体

    下载SimHei字体(或者其他的支持中文显示的字体也行)
    whindows下或者mac下:双击安装就可以了
    linux下:拷贝字体到usr/share/fonts下:
    借用管理员的权限拷贝:sudo cp ~/SimHei.ttf /usr/share/fonts/SimHei.ttf
    linux如果用的是乌版图系统也可以双击安装

    第2步 删除matplotlib缓存文件

    mac系统:
    cd ~/.matplotlib
    rm -r *
    linux:
    cd ~/.cache/matplotlib
    rm -r *

    第3步 修改配置文件matplotlib

    mac :
    vi ~/.matplotlib/matplotlibrc
    将文件内容修改为:
    font.family :sans-serif
    font.sans-serif :SimHei
    axes.unicode_minus :False

    linux:
    sudo find -name matplotlibrc
    返回结果:
    ./.virtualenvs/ai/lib.python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
    打开配置文件
    vi ./.virtualenvs/ai/lib.python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
    将配置文件中下面三项改为如下所示:
    font.family :sans-serif
    font.sans-serif :SimHei
    axes.unicode_minus :False

  • 相关阅读:
    9.17
    9.14
    9.13
    9.13
    9.11
    9.28
    10 .19 知识点
    redux
    react路由
    react的三大属性
  • 原文地址:https://www.cnblogs.com/duanming/p/11830281.html
Copyright © 2011-2022 走看看