问题
在docker容器里启动jupyter后,使用plt画图时中文有乱码。
解决
下载SimHei.ttf
链接:Download Free Font SimHei
然后在jupyter里运行如下代码,获取要放置simhei.ttf的目录
import matplotlib as mpl
d0 = mpl.matplotlib_fname()
d1=d0.replace('matplotlibrc', 'fonts/ttf')
print('1. 将SimHei.ttf放到如下目录:n%s' % d1)
print('2. 清空缓存目录:n%s' % (mpl.get_cachedir()))
print('3. 修改配置文件:%s' % d0)
修改配置文件 matplotlibrc:
将一下三句修改,并将 # 去掉:
font.family : sans-serif ... font.sans-serif : SimHei ... axes.unicode_minus : False # use unicode for the minus symbol



