zoukankan      html  css  js  c++  java
  • 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、删除缓存目录

  • 相关阅读:
    POJ 2018 二分
    873. Length of Longest Fibonacci Subsequence
    847. Shortest Path Visiting All Nodes
    838. Push Dominoes
    813. Largest Sum of Averages
    801. Minimum Swaps To Make Sequences Increasing
    790. Domino and Tromino Tiling
    764. Largest Plus Sign
    Weekly Contest 128
    746. Min Cost Climbing Stairs
  • 原文地址:https://www.cnblogs.com/touristlee/p/8805655.html
Copyright © 2011-2022 走看看