惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - longbigfish

部署(https证书) https证书问题(本地) 参数更新 Ubuntu 24安装Neo4j详细教程 protect 紧急 手机 刷脏页的两种模式 python中的多线程陷阱与pytorch分布式执行机制 git之复合指令和submodule rpc编程示例 mpi编程 cifs远程挂载 使用脚本进入一个命令行控制台,并预设执行的命令列表 cifs挂载远程文件出现 No such device or address错误 longtable 跨越多个页面时,如何在跨页时自动断行并加上横线及去掉页眉 latex编译过程-关于嵌入所有字体 python做图笔记 linux启动全过程 连接并同步windows下的git仓库 反向ssh
matplotlib中文显示-微软雅黑
longbigfish · 2018-09-17 · via 博客园 - longbigfish

网上有很多方法,但是基本的是片面的。

参考1 https://tracholar.github.io/wiki/python/matplotlib-chinese-font.html

参考2 https://www.cnblogs.com/touristlee/p/8805655.html

windows下,做到以下三点,可以成功

(1)现在msyh.ttf字体,放到matplot的字体目录,

      路径如 D:\Program\Anaconda3\Lib\site-packages\matplotlib\mpl-data

        参考1有示例

      使用下面代码找路径

import matplotlib
print(matplotlib.matplotlib_fname())

(2)修改文件,matplotlibrc

    参考1或参考2

(3) 删除缓存,很重要!

    具体i方式是首先删除 C:\Users\你的用户名\.matplotlib 把这个.matplotlib文件夹删掉,然后重启应用。

5. 直接使用 

plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签 

也可以显示中文,但是这样显示的英文又不是很美观。SimHei应该是matplotlib自带的字体。

6. 注意!!!

使用SimHei 或 Microsoft YaHei 后,生成的pdf文件特别大,前者是4MB多,后者是8MB多,而默认英文字体只有470KB多。

另外,一旦运行了plt.rcParams['font.sans-serif'] = ['SimHei']  ,除非重启应用,否则运行其他文件也是使用该字体,生成很大的pdf

7. 参考 http://www.yeolar.com/note/2011/04/28/matplotlib-tips/

http://blog.sciencenet.cn/blog-43412-343002.html

8. 这个可行,最好,文件小

https://www.v2ex.com/t/317361

保存pdf出错,truetype ..

9. 最终,还是觉得先生成pdf文件,然后在acrobat里改中文最好

使用 

plt.rcParams['font.sans-serif'] = ['Times New Roman'] 设置全局字体. 不过这个'Times New Roman' 怎么显示黑体?