当前位置:网站首页>Matplotlib找不到字体,打印乱码
Matplotlib找不到字体,打印乱码
2022-08-11 05:28:00 【秋天已北】
# 使文字可以展示
plt.rcParams['font.sans-serif'] = ['SimHei']
# 使负号可以展示
plt.rcParams['axes.unicode_minus'] = False
前提是得安装对应字体
可以再windows环境找到字体文件
C:\Windows\Fonts
复制到Matplotlib字体路径内
data/app/miniconda3/envs/py_test38/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/
可以通过如下代码查看当前支持的字体
import matplotlib.pyplot as plt
from matplotlib import font_manager
for font in font_manager.fontManager.ttflist:
# 查看字体名以及对应的字体文件名
print(font.name, '-', font.fname)
修改
vi /data/app/miniconda3/envs/py_test38/lib/python3.8/site-packages/matplotlib/mpl-data/matplotlibrc
放开这两行注释 并在可用列表中增加 SimHei 中文字体
font.family: sans-serif
font.sans-serif: SimHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
删除缓存文件
rm ~/.cache/matplotlib/fontlist-v330.json
重启python
边栏推荐
猜你喜欢
第四范式OpenMLDB优化创新论文被国际数据库顶会VLDB录用
EMQX企业版试用笔记
Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain
js 学习进阶(Dom部分 pink老师教学笔记)
OpenMLDB: Consistent production-level feature computing platform online and offline
Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched
Fourth Paradigm OpenMLDB optimization innovation paper was accepted by VLDB, the top international database association
The third phase of the contributor task is wonderful
gerrit 配置SSH Key和账号、邮箱信息
精彩联动 | OpenMLDB Pulsar Connector原理和实操
随机推荐
Day 68
scanf函数在混合接受数据(%d和%c相连接)时候的方式
Asp doNet Mvc4绑定js脚本用法
STM32-库函数-SetSysClock(void)函数解析-正点原子探索者
经纬度求距离
js 学习进阶(Dom部分 pink老师教学笔记)
Invalid revision: 3.18.1-g262b901-dirty
OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering
He Kaiming's new work ViTDET: target detection field, subverting the concept of layered backbone
使用adb命令管理应用
无效的修订:3.18.1-g262b901-dirty
net6的Web MVC项目实现限流功能
The whole process of Tinker access --- Compilation
哥德巴赫猜想与整数环
vim 编辑解决中文乱码问题
The Summer of Open Source 2022 is coming | Welcome to sign up for the OpenMLDB community project~
JNI入门
STM32F407-浅~~析UART异步通信&USART_Init函数入口参数
openlayer中实现截图框截图的功能
OpenMLDB + Jupyter Notebook: Quickly Build Machine Learning Applications