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

相关推荐
gzroy12 小时前
量化金融实践-海龟交易法
python·金融
sg_knight12 小时前
适配器模式(Adapter)
python·设计模式·适配器模式·adapter
52Hz11812 小时前
力扣20.有效的括号、155.最小栈
python·算法·leetcode
小鸡吃米…13 小时前
TensorFlow 实现多层感知机学习
人工智能·python·tensorflow
WW、forever13 小时前
【服务器】上传服务器中数据至 FigShare(Python)
运维·服务器·python
宝贝儿好13 小时前
【强化学习】第十章:随机高斯策略
人工智能·python·深度学习·神经网络·机器人·自动驾驶
haosend13 小时前
【练习版】使用paramiko批量的查询,管理,配置路由器交换机
python·路由器·交换机·网络自动化
Dxy123931021613 小时前
Python生成随机手机号码
开发语言·python
YQ_0114 小时前
Ubuntu下安装WPS
linux·ubuntu·wps
小志biubiu14 小时前
Linux_进程概念(A)-进程部分【Ubuntu】
linux·运维·服务器·ubuntu·操作系统·进程