解决matplotlib图中的中文显示方框
中文matplotlib 解决 显示 图中
2023-09-11 14:22:20 时间
1、复制字体到系统目录:sudo cp winfonts/simhei.ttf /usr/share/fonts/TTF/
2、复制字体到matplotlib的字体目录中:sudo cp winfonts/simhei.ttf /usr/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/
3、修改配置文件:sudo vim /usr/lib/python3.10/site-packages/matplotlib/mpl-data/matplotlibrc,将simhei信息添加,具体就是:
1 font.family: simhei, sans-serif 2 #font.style: normal 3 #font.variant: normal 4 #font.weight: normal 5 #font.stretch: normal 6 font.size: 14.0 7 8 font.serif: simhei, DejaVu Serif, Bitstream Vera Serif, Computer Modern Roman, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif 9 font.sans-serif: simhei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
分别在第1、8、9行添加字体信息
4、python WORKM/pythonCode/chapter15/mplSquares.py结果:
终于好了,接着,再看下一章随意长相的猫吧。
感谢:https://zhuanlan.zhihu.com/p/52779214
相关文章
- 分词之最短编辑距离算法实现(包括中文)
- 【JAVA】MyEclipse中JSP页面出现中文乱码问题(3种情况的解决方案)
- 28 爬虫 - re 正则 匹配中文
- Matplotlib基础--在 matplotlib 中创建三维图表
- Win7下 Python中文正则的奇异表现
- android api 中文 (75)—— AdapterView.OnItemClickListener
- Linux sort命令中文手册(info sort翻译)
- SwiftUI 实战之带文本框TextField的Alert组件解决中文问题(教程含源码)
- VectorArithmetic (SwiftUI 中文文档手册)
- Elasticsearch + logstash中文指南
- 一、UC中文调试
- Ubuntu环境下 matplotlib 图例中文乱码
- Windows下IDEA run能运行springboot,java -jar maven打的包拉有中文的nacos配置,报org.yaml.snakeyaml.error.YAMLException错误解决
- [解决]Github Desktop中History历史文件预览有中文乱码问题
- 修复Kaos的中文显示
- IDEA上Java项目控制台中文乱码