美文网首页
matplotlib 中文乱码

matplotlib 中文乱码

作者: lesliefang | 来源:发表于2017-07-27 14:21 被阅读146次
  1. 执行下面的代码找到配置文件路径
 import matplotlib
 matplotlib.matplotlib_fname()

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc

  1. 修改 matplotlibrc 文件
    font.family : sans-serif
    font.sans-serif : SimHei, sans-serif
    把本机的中文字体放在 font.sans-serif 的最前面,如这里的 SimHei
  2. 如果找不到本机的中文字体,就下载一个 http://www.fontpalace.com/font-details/SimHei/
    放到 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf 文件夹下
  3. 重启 jupyter notebook

相关文章

网友评论

      本文标题:matplotlib 中文乱码

      本文链接:https://www.haomeiwen.com/subject/foyzkxtx.html