Welcome To My Blog
安装了Anaconda3,学着用matplotlib,发现不能显示中文,查阅了网上的方法,对matplotlibrc中的font.family各种改,但Jupyter Noterbook依旧显示UserWarning: findfont: Font family
最终找到解决方法,操作很简单:
.matplotlib(图一)这个目录里,注意文件夹名字最前面是个点,有个叫fontList.json(图二)的文件,这个目录与我的Anaconda3在同一个目录中,
打开后在ttffiles(图三)对应的列表中显示的就是matplotlib可以加载的字体,涵盖的字体路径有Anaconda自带的,也有系统自带的,我选择了系统自带的黑体(图四),最后打开Anaconda3\Lib\site-packages\matplotlib\mpl-data的matplotlibrc,把font.family改成simhei(图五)(注意去掉前面的#号),重新启动Jupyter Noterbook即可显示中文

matplotlib显示中文(解决UserWarning: findfont: Font family)
图一

matplotlib显示中文(解决UserWarning: findfont: Font family)
图二

matplotlib显示中文(解决UserWarning: findfont: Font family)
图三

matplotlib显示中文(解决UserWarning: findfont: Font family)
图四

matplotlib显示中文(解决UserWarning: findfont: Font family)
图五

WelcomeToMyBlog

相关文章:

  • 2021-12-15
  • 2021-07-22
  • 2021-09-18
  • 2022-12-23
  • 2021-12-14
  • 2021-06-08
  • 2021-12-29
猜你喜欢
  • 2021-10-31
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2023-03-19
相关资源
相似解决方案