Font family [‘sans-serif‘] not found.Falling back to DejaVu Sans.解决办法
1、在终端python 的环境下,查看字体路径
import matplotlib
print(matplotlib.matplotlib_fname())
2、下载SimHei
官方下载网址,并前往指定目录:/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf,将下载好的SimHei移动到该目录下。
3、删除matplotlib的缓冲目录
在终端python 的环境下,输入如下指令,查看matplotlib的字体缓存路径:
import matplotlib
matplotlib.get_cachedir()
然后使用rm -rf +路径删除缓存

4、修改matplotlibrc文件
修改/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc,修改内容如下:
font.family : sans-serif
# 去掉前面的#
font.sans-serif : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
# 去掉前面的#,并在冒号后面添加SimHei
axes.unicode_minus : False
# 去掉前面的#,并将True改为False