1.下载下载中文 arial unicode ms 字体到 /home 目录

2. 拷贝字体到 usr/share/fonts 下:

  • sudo cp ~/arial\ unicode\ ms.ttf /usr/share/fonts/arial\ unicode\ ms.ttf

3. 修改配置文件,运行下列代码查看配置文件位置

  • import matplotlib
    print(matplotlib.matplotlib_fname()) #输出配置文件位置
    # eg:/home/python/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc

进入到上述找到的配置文件中,修改下面两项

sudo vim /home/python/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc
# 打开这一行注释
font.family : sans-serif
# 在原有字体之前,新增我们刚下载的中文字体 arial unicode ms
font.sans-serif : arial unicode ms, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

4. 这一步骤最重要!为matplotlib增加中文字体.将下载的arial unicode ms.ttf字体文件复制一份到步骤2找到的配置文件的同级文件夹fonts中:

sudo cp ~/arial\ unicode\ ms.ttf /home/python/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/arial\ unicode\ ms.ttf

5. 清除本地matplotlib中的缓存

  • rm -rf ~/.cache/matplotlib

现在就可以重新画图,查看中文效果了。

Linux中matplotlib 中文显示问题解决的更多相关文章

  1. linux中vim中文显示乱码

    这里所说的都是全局设定,打开vimrc文件后,只需要在文件最后添加以下代码就可以了: set fileencodings=utf-8,gb2312,gbk,gb18030 set termencodi ...

  2. python matplotlib 中文显示参数设置

    python matplotlib 中文显示参数设置 方法一:每次编写代码时进行参数设置 #coding:utf-8import matplotlib.pyplot as pltplt.rcParam ...

  3. mysql插入表中的中文显示为乱码或问号的解决方法

    版权声明:本文为博主原创文章,未经博主允许不得转载. 今天在做ssh的博客项目时发现mysql数据库中的中文显示为问号,网上查阅了很多资料,都不是很全,所以我总结一下,供大家参考和自己复习. 1.我的 ...

  4. Matplotlib中文显示的问题

    原文地址:http://blog.csdn.net/rumswell/article/details/6544377 #Matplotlib中文显示有问题,当然可以修改配置文件matplotlibrc ...

  5. python matplotlib 中文显示乱码设置

    python matplotlib 中文显示乱码设置 原因:是matplotlib库中没有中文字体.1 解决方案:1.进入C:\Anaconda64\Lib\site-packages\matplot ...

  6. Jsp页面中的中文乱码问题解决

    Jsp页面中的中文乱码问题解决 在编写Jsp页面的时候,发现写入其中的中文在浏览器浏览的时候会出现乱码的情况. 出现乱码的原因分析: 因为页面中对自己的编码格式的声明和页面的实际编码格式不相同,而浏览 ...

  7. matplotlib中文显示乱码解决方法

    在学习<机器学习实战>这本书的决策树一章时,要用matplotlib画出决策树,然而在显示中文时出现了乱码 import matplotlib.pyplot as plt #定义文本框和箭 ...

  8. 在Linux中让文本显示带颜色的字。

    在linux中让echo命令显示带颜色的字需要使用参数-e 格式:echo -e "\33[字体背景颜色:文字颜色m字符转\033[0m" 注: 1.字体背景颜色和文字颜色之间是英 ...

  9. matplotlib 中文显示问题

    matplotlib 默认显示不了中文,如果想显示中文,通过下面代码设置: import matplotlib #指定默认字体 matplotlib.rcParams['font.sans-serif ...

随机推荐

  1. springboot寻找property的顺序

    Spring Boot uses a very particular PropertySource order that is designed to allow sensible overridin ...

  2. JQuery的可见性选择器

    1. <div id="test" style="width:400px;height:200; background:#0000ff;display:block; ...

  3. 7za命令报错Error: xxx is not supported archive

    问题: 执行7za命令时报错:Error: xxx is not supported archive   原因: 当前7za版本过低   直接执行7za可以看到当前版本: 7-Zip (A) [64] ...

  4. jQuery开发工具

    开发工具:MyEclipse2014 + aptana插件 下载apada 放到MyEclipse的路径   https://segmentfault.com/a/1190000005711923   ...

  5. c++ 面试题(C/C++/STL)

    1,智能指针:auto_ptr(c++11 已经弃用),unique_ptr(用于取代 auto_ptr),  shared_ptr,  weak_ptr http://www.cnblogs.com ...

  6. 使用 Composer 安装Laravel扩展包的几种方法

    使用 Composer 安装Laravel扩展包的几种方法 以下的三种方法都是需要你在项目的根目录运行 第一种:composer install 如有 composer.lock 文件,直接安装,否则 ...

  7. [leetcode]364. Nested List Weight Sum II嵌套列表加权和II

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  8. 根据需要查找需要的第三方pyhton库

    1.可以在https://awesome-python.com/这个网站上按照分类去寻找,上面收录了比较全面的第三方库.比如我们想要找爬虫方面的库时,查看Web Crawling这个分类,就能看到相应 ...

  9. zeromq学习记录(七)订阅发布消息封装

    之前也有提到 使用订阅发布 pub sub模式必须要显示定义ZMQ_SUBSCRIBE 只有以此模式定义的过滤字节开头的消息才会被订阅者收到 如果想收到所有信息 可定义subscriber.setso ...

  10. 快速解决MariaDB无密码就可以登录的问题

    mysql  Ver 15.1 Distrib 10.1.37-MariaDB, for Linux (x86_64) using readline 5.1 #mysql -uroot -p #del ...