#Matplotlib,jupyter中文乱码解决方案
####解决方案
import matplotlib
sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])
#要保证从拷到python安装目录的ttf目录下的字体名称的正确性
这里注意的就是【Mircosoft YaHei UI】与 【MSYH.TTC】并不相同,但都是同一种字体,而且我们在matplotlibrc文件中要用的字体名是【Mircosoft YaHei】,这并不矛盾,因为字体要已python 字体库为准,字体名列表都在以上代码中。
4. 定位matplotlibrc文件
该文件位于[your python_install_path]\Lib\site-packages\matplotlib\mpl-data目录下。配置文件如下:
# 12pt is the standard value.
#
font.family : Microsoft YaHei
#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 : 12.0
#font.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
#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
致谢 知乎hengchao0248的回答与csdn