Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

中文字体乱码 #6

Open
Hanyx2021 opened this issue Dec 21, 2024 · 5 comments
Open

中文字体乱码 #6

Hanyx2021 opened this issue Dec 21, 2024 · 5 comments

Comments

@Hanyx2021
Copy link

Hanyx2021 commented Dec 21, 2024

matplotlib绘制图表时默认不使用中文字符,如果出现乱码请安装中文字体,以SimHei为例

wget -O simhei.ttf "https://www.wfonts.com/download/data/2014/06/01/simhei/chinese.simhei.ttf"

并在main.py中添加

matplotlib.font_manager.fontManager.addfont('simhei.ttf')
matplotlib.rc('font', family='SimHei')
@leverimmy
Copy link
Owner

请问您的操作系统是什么?是 Linux 还是 Windows 呀?

@Hanyx2021
Copy link
Author

Linux

@Lethe10137
Copy link
Contributor

我是Ubuntu 22.04, 我在 #9 给出了一个只用修改代码的解决方案

@leverimmy
Copy link
Owner

已由 Lethe10137#9 中修复,感谢大家!

@seekstar
Copy link

不是所有Linux都有这个字体:Droid Sans Fallback,例如我的Arch Linux就没有。这个PR在出现这种情况时可以自动找到一个能用的字体:#13

@leverimmy leverimmy reopened this Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants