✨
Matplotlib Chinese Font
Matplotlib Chinese Font · v1.0.0
963 下载
0 安装
4.8k 收藏
5 浏览
简介
Matplotlib Chinese Font
原始描述
Configure Chinese fonts for matplotlib plotting. Use when plotting charts with Chinese characters or getting garbled text.
通过你的 Agent 添加
安装目录:matplotlib-chinese-font/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
Claude Code~/.claude/skills/matplotlib-chinese-font/
Codex CLI~/.codex/skills/matplotlib-chinese-font/
DeepSeek Harness~/.agents/skills/matplotlib-chinese-font/
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: matplotlib-chinese-font
description: Configure Chinese fonts for matplotlib plotting. Use when plotting charts with Chinese characters or getting garbled text.
Matplotlib 中文字体配置
何时使用
- matplotlib 图表中出现中文乱码(显示为方块)
- 需要在图表中使用中文标题、标签、图例
- 需要区分不同中文字体效果(如宋体 vs 黑体)
快速配置
方法 1:全局配置(推荐)
import matplotlib.pyplot as plt
# 配置中文字体
plt.rcParams['font.sans-serif'] = ['Heiti TC'] # 华文黑体
plt.rcParams['axes.unicode_minus'] = False # 解决负号显示问题
# 绘制图表
plt.plot([1, 2, 3], [1, 2, 3])
plt.title('测试标题', fontsize=14)
plt.xlabel('X 轴')
plt.ylabel('Y 轴')
plt.show()
方法 2:强制指定字体(更可靠)
何时使用
方法 1:全局配置(推荐)
import matplotlib.pyplot as plt
# 配置中文字体
plt.rcParams['font.sans-serif'] = ['Heiti TC'] # 华文黑体
plt.rcParams['axes.unicode_minus'] = False # 解决负号显示问题
# 绘制图表
plt.plot([1, 2, 3], [1, 2, 3])
plt.title('测试标题', fontsize=14)
plt.xlabel('X 轴')
plt.ylabel('Y 轴')
plt.show()
当全局配置不生效时,在具体元素上强制指定:
plt.title('图表标题', fontsize=14, fontname='Heiti TC')
plt.xlabel('X 轴', fontsize=12, fontname='Heiti TC')
plt.ylabel('Y 轴', fontsize=12, fontname='Heiti TC')
plt.text(0.5, 0.5, '文本标注', fontname='Heiti TC')
可用字体
常用系统字体:
- Heiti TC - 华文黑体(用户偏好)
- Songti SC - 华文宋体
查询所有可用字体:
python3 -c "import matplotlib.font_manager as fm; print('\n'.join(sorted(set([f.name for f in fm.fontManager.ttflist]))))"
常见问题
字体不生效
-
清除字体缓存
rm -rf ~/.matplotlib或运行
scripts/clear_cache.py -
强制指定字体 使用
fontname参数而不是rcParams -
检查字体是否存在 运行
scripts/list_fonts.py查看系统可用字体
负号显示为方块
plt.rcParams['axes.unicode_minus'] = False
保存图片时中文乱码
plt.rcParams['axes.unicode_minus'] = False
确保保存前字体已正确设置:
plt.savefig('/tmp/chart.png', dpi=120, bbox_inches='tight')
脚本工具
scripts/clear_cache.py - 清除 matplotlib 字体缓存
scripts/list_fonts.py - 列出系统可用中文字体
scripts/test_font.py - 测试指定字体的显示效果
参考资料
references/troubleshooting.md - 详细问题排查指南
scripts/clear_cache.py - 清除 matplotlib 字体缓存scripts/list_fonts.py - 列出系统可用中文字体scripts/test_font.py - 测试指定字体的显示效果references/troubleshooting.md- 详细问题排查指南
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。
标签
同类 Skill
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
Self-Improving + Proactive Agent
Self-Improving + Proactive Agent
下载 177.1k
✨
Gog
Gog
下载 165k