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

  • 相关阅读:
    猿辅导-去除数组中数量大于k的数
    OSI体系结构各层协议
    京东-学生合唱队分组
    146-LRUCache
    76-最长上升子序列
    无序数组中三个数字乘积最大值
    38-字符串的排列
    35-复杂链表的复制
    208-Implement Trie(Prefix Tree)
    69-求一个整数的平方根
  • 原文地址:https://www.cnblogs.com/duanming/p/11830281.html
Copyright © 2011-2022 走看看