admin管理员组文章数量:1594755
Ubuntu
安装中文字体&解决Jupyter中文字体乱码显示问题
import matplotlib.pyplot as plt
plt.title('中文')
plt.figure()
0 查看Ubuntu
字体目录
!ls /usr/share/fonts/
1 通过apt-get
安装
step1: 安装
文泉驿-正黑
字体
!apt-get install ttf-wqy-zenhei -y
step2: 查看是否安装成功
!fc-list :lang=zh
2 自己下载字体安装
step1: 下载字体并解压
!wget http://www.mycode/wp-content/uploads/2015/07/YaHeiConsolas.tar.gz
!tar -zxvf YaHeiConsolas.tar.gz
step2: 创建
vista
目录 & 字体复制到该目录下
!mkdir -p /usr/share/fonts/vista
!cp YaHeiConsolas.ttf /usr/share/fonts/vista/
查看是否复制成功
!ls /usr/share/fonts/vista/
step3: 安装字体
!cd /usr/share/fonts/vista/
!mkfontscale && mkfontdir && fc-cache -fv
step4: 查看是否安装成功
!fc-list :lang=zh
3 测试能否显示
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", size=20)
plt.title(u'中文',fontproperties=font_set)
plt.figure()
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", size=20)
plt.title(u'中文',fontproperties=font_set)
plt.figure()
版权声明:本文标题:Ubuntu安装中文字体&解决Jupyter中文字体乱码显示问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728202705a1149592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论