jupyter notebook中matplotlib绘图包的中文乱码问题

方法1,root态安装

  1. 停止Jupyter
  2. 安装 font-manager: sudo apt install font-manager
  3. 清除matplotlib cache directory: rm ~/.cache/matplotlib -fr
  4. 重启Jupyter.

方法2,用户态安装

1. 查找matplotlib路径

import matplotlib
matplotlib.matplotlib_fname()

输出路径大致如下,记住,第2步会使用:

‘xxx/matplotlib/mpl-data/matplotlibrc’

2. 安装SimHei字体

字体链接:百度网盘 密码:5vn4

字体放到xxx/matplotlib/mpl-data/ttf下即可

3. 修改配置文件

vim 打开xxx/matplotlib/matplotlibrc,添加内容如下:
image

4. 删除缓存

rm ~/.cache/matplotlib -fr

重启jupyter即可。

发布了89 篇原创文章 · 获赞 37 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/u012891055/article/details/82288251
今日推荐