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

相关推荐
SilentSamsara1 天前
Python 环境搭建完整指南:从下载安装到运行第一个程序
开发语言·python
zhoutongsheng1 天前
C#怎么实现Swagger文档 C#如何在ASP.NET Core中集成Swagger自动生成API文档【框架】
jvm·数据库·python
拾贰_C1 天前
【Agent | openai | Streaming | 】流式输出Streaming
ubuntu·面试·prompt
.5481 天前
## Sorting(排序算法)
python·算法·排序算法
ydmy1 天前
注意力机制(个人理解)
pytorch·python·深度学习
iwhitney1 天前
【次方量化】3分钟搞懂什么是量化策略
python
高洁011 天前
大模型部署资源不足?轻量化部署解决方案
python·深度学习·机器学习·数据挖掘·transformer
阿里云大数据AI技术1 天前
MaxFrame 视频帧智能分析:从视频到语义向量的端到端分布式处理
人工智能·python
淘矿人1 天前
从0到1:用Claude启动你的第一个项目
开发语言·人工智能·git·python·github·php·pygame
嘻嘻哈哈樱桃1 天前
牛客经典101题题解集--动态规划
java·数据结构·python·算法·职场和发展·动态规划