Ubuntu16.04 python matplotlib 输出轴标签出现中文乱码

  • 问题:坐标轴打印中文时,显示会乱码
python 复制代码
import matplotlib.pyplot as plt
plt.ylabel('时间刻度')
  • 原因:matplotlib里面没有中文字体
  • 解决方法:下载SimHei字体,快捷方法是使用everything直接在windows搜索simhei.ttf,再拖进Ubuntu就可以了
  • 最后在程序里面加入字体的路径就可以了
python 复制代码
import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.xlabel('横轴标签', fontproperties=FontProperties(fname='/home/your_path/simhei.ttf',))
plt.ylabel('纵轴标签', fontproperties=FontProperties(fname='/home/your_path/simhei.ttf'))

Reference

相关推荐
Zhansiqi7 小时前
day42部分题目
python
小王不爱笑1327 小时前
IO 模型
开发语言·python
kishu_iOS&AI7 小时前
Conda 简要说明与常用指令
python·安全·conda
小陈工7 小时前
FastAPI性能优化实战:从每秒100请求到1000的踩坑记录
python·性能优化·django·flask·numpy·pandas·fastapi
知我Deja_Vu8 小时前
【避坑指南】ConcurrentHashMap 并发计数优化实战
java·开发语言·python
njidf8 小时前
用Python制作一个文字冒险游戏
jvm·数据库·python
呆呆小孩8 小时前
Anaconda 被误删抢救手册:从绝望到重生
python·conda
liliangcsdn8 小时前
LLM复杂数值的提取计算场景示例
人工智能·python
人工智能AI酱8 小时前
【AI深究】逻辑回归(Logistic Regression)全网最详细全流程详解与案例(附大量Python代码演示)| 数学原理、案例流程、代码演示及结果解读 | 决策边界、正则化、优缺点及工程建议
人工智能·python·算法·机器学习·ai·逻辑回归·正则化
WangLanguager8 小时前
逻辑回归(Logistic Regression)的详细介绍及Python代码示例
python·算法·逻辑回归