version

Ubuntu16.04

python3.6.2

Specific steps

  1. Run the code
#! usr/bin/env python #-*- coding:utf-8 _*- """ @author:fonttian @file: testCN.py @time: 2017/09/26 """ from matplotlib.font_manager import FontManager import subprocess fm = FontManager() mat_fonts = set(f.name for f in fm.ttflist) output = subprocess.check_output( 'fc-list :lang=zh -f "%{family}\n"', Shell =True) output = output.decode('utf-8') # print '*' * 10 ', '*' * 10 # print output zh_fonts = set(f.split(',', 5)[0] for f in output.split('\n')) available = mat_fonts & zh_fonts print('*' * 10, ' ' '*' * 10) for f in available: print(f) import matplotlib print(matplotlib.matplotlib_fname())Copy the code

2. Obtain information output:

* * * * * * * * * * available font * * * * * * * * * * Yahei Mono Yahei Consolas Hybrid / home/fonttian anaconda3 / lib/python3.6 / site - packages/matplotlib/MPL - data/matplotlibrcCopy the code

The first two are available fonts, if not, you need to download them yourself. The last line is the address of the configuration file that needs to be changed. Then, delete the # in the file: delete the # before the font

3. Delete ~/. Cache /matplotlib,(CTRL +H, display hidden files) 4. Run the test file, a test file is given here

import numpy as np import pylab as pl import matplotlib as mpl mpl.rcParams['font.sans-serif'] = ['Yahei Mono'] Mpl.rcparams [' font-size. Serif '] = ['Yahei Mono'] t = np.arange(0.0,2.0 * Np.pi,0.01) # Pl.plot (t,s,label=' sine ') pl.xlabel('x- variable ') # Set label pl.ylabel('y- sine - cosine ') Pl.title ('sin-cos function image ') #Copy the code

5. Pandas

other

Any reference: it is recommended that the reference content: www.zhihu.com/question/25… Win: blog.csdn.net/fontthrone/…