• win10系统matplotlib中文显示问题


    matplotlib画图时,中文字符显示为乱码,需要自行添加字体库。win10系统自带的字体库和matplotlib不能通用,因此需要在网上下载一个,

    微软雅黑的字体这边收藏在网盘里,可以直接拿去用。https://pan.baidu.com/s/1pCAcbRuIh7WLIfbT-5BbZA

    把字体文件放在D:\Anaconda2\Lib\site-packages\matplotlib\mpl-data\fonts\ttf目录下面,放置目录需要根据自己的安装目录修改一下。

    接下来修改一下配置文件D:\Anaconda2\Lib\site-packages\matplotlib\mpl-data\matplotlibrc 修改非注释部分。

    最后删除一下缓存目录,在路径C:\Users\你的用户名\.matplotlib 把这个.matplotlib整个文件夹删除。

    然后去测试一下能否显示中文,保险起见可以重启一下应用。

    
    

    # The font.size property is the default font size for text, given in pts.
    # 10 pt is the standard value.
    #
    font.family : sans-serif
    #font.style : normal
    #font.variant : normal
    #font.weight : medium
    #font.stretch : normal
    # note that font.size controls default text sizes. To configure
    # special text sizes tick labels, axes, labels, title, etc, see the rc
    # settings for axes and ticks. Special text sizes can be defined
    # relative to font.size, using the following values: xx-small, x-small,
    # small, medium, large, x-large, xx-large, larger, or smaller
    #font.size : 10.0
    #font.serif : DejaVu Serif, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
    font.sans-serif : Microsoft YaHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
    #font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive

     

    主要步骤只有两步,

    1、添加字体库

    2、修改配置文件

    3、删除缓存目录

  • 相关阅读:
    FJNUOJ Yehan’s hole(容斥求路径数 + 逆元)题解
    FJNUOJ the greed of Yehan(最长路 + 权值乘积转化)题解
    BZOJ 2956 模积和
    BZOJ 2299 向量
    codeforces 718c Sasha and Array
    BZOJ 3747 Kinoman
    BZOJ 2431 逆序对数列
    BZOJ 3289 Mato的文件管理
    BZOJ 3781 小B的询问
    BZOJ 2038 小Z的袜子(hose)
  • 原文地址:https://www.cnblogs.com/touristlee/p/8805655.html
Copyright © 2020-2023  润新知