当前位置:网站首页>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
边栏推荐
- 需求文档(PRD)撰写指南
- JS advanced web page special effects (pink teacher notes)
- 字节(byte)和位(bit)
- Intelligent risk control China design and fall to the ground
- Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain
- promise.all 学习(多个promise对象回调)
- 华为IOT平台温度过高时自动关闭设备场景试用
- vscode插件开发——代码提示、代码补全、代码分析
- Here is a memorial
- 系统性能及并发数的一些计算公式
猜你喜欢

STM32-库函数-SetSysClock(void)函数解析-正点原子探索者

ActiveReports报表分类之页面报表

Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain

使用adb命令管理应用

华为云IOT平台设备获取api调用笔记

JNI入门

Jetpack使用异常问题集锦

贡献者任务第三期精彩来袭

厂商推送平台-华为接入

开源之夏 2022 火热来袭 | 欢迎报名 OpenMLDB 社区项目~
随机推荐
mysql basic summary
USB in NRZI to encode the data
aPaaS和iPaaS的区别
OpenMLDB v0.5.0 released | Performance, cost, flexibility reach new heights
构建面向特征工程的数据生态 ——拥抱开源生态,OpenMLDB全面打通MLOps生态工具链
mount命令--挂载出现只读,解决方案
JVM调优整理
He Kaiming's new work ViTDET: target detection field, subverting the concept of layered backbone
Day 70
栈stack
批量快速修改代码的正则表达式替换
Vscode remote connection server terminal zsh+Oh-my-zsh + Powerlevel10 + Autosuggestions + Autojump + Syntax-highlighting
Day 78
STM32F4-正点原子探索者-SYSTEM文件夹下的delay.c文件内延时函数详解
net6 的Web MVC项目中事务功能的应用
实时特征计算平台架构方法论和基于 OpenMLDB 的实践
Vscode远程连接服务器终端zsh+Oh-my-zsh + Powerlevel10 + Autosuggestions + Autojump + Syntax-highlighting
Day 67
STM32学习笔记(白话文理解版)—外部IO中断实验
JS case exercise (classic case of teacher pink)