栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

安装中文字体 ubuntu | matplotlib

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

安装中文字体 ubuntu | matplotlib

安装字体管理工具

弹出对话框拉到最下面,选OK和Yes

sudo apt-get install ttf-mscorefonts-installer
移动字体到对应路径
sudo mkdir /usr/share/fonts/winfonts
sudo mv SimHei.ttf /usr/share/fonts/winfonts 
更新字体
sudo mkfontscale 
sudo mkfontdir
sudo fc-cache -fsv
删除matplotlib缓存
rm -rf ~/.cache/matplotlib/*
测试
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
eurcny_2017 = np.array([6.8007, 6.8007, 6.8015, 6.8015, 6.8060,  6.8060, 6.8060, 6.8036, 
6.8025, 6.7877, 6.7835, 6.7758, 6.7700, 6.7463, 6.7519,6.7511, 
6.7511, 6.7539, 6.7265])
eurcny_2019 = np.array([6.8640, 6.8705, 6.8697, 6.8697, 6.8697,6.8881, 6.8853, 6.8856,
6.8677, 6.8662, 6.8662, 6.8662, 6.8827, 6.8761, 6.8635,6.8860, 
6.8737, 6.8796, 6.8841]) 
date_x = np.array([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 19, 24, 25, 26, 31])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(date_x, eurcny_2017, color='hotpink', linewidth=3,linestyle=':',label='2017年7月美元/人民币汇率')
ax.plot(date_x, eurcny_2019, color='#8a2e76', linestyle='--', linewidth=2, label='2019年7月美元/人民币汇率')
ax.set_title('2017年7月与2019年7月美元/人民币汇率走势')  
ax.set_xlabel('日期')
ax.set_ylabel('汇率')
ax.legend()
plt.show()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/882425.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号