cjk-viz
CJK (中日韩) 字体检测与 matplotlib 配置。任何涉及中文标签、标题、图例的 可视化任务启动前必须先执行本 skill 的字体检测流程,确保不会出现方块乱码。 适用于 matplotlib / seaborn / plotly 静态导出等场景。
npx skills add BioTender-max/awesome-bio-agent-skills --skill cjk-viz --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# CJK 可视化字体配置 ## 何时使用 任何绘图代码中包含中文文本(标题、轴标签、图例、注释)时,**必须在绘图前** 执行字体检测。不要假设某个字体一定存在。 ## 快速使用 ### 方式一:导入 helper(推荐) 将 `scripts/setup_cjk_font.py` 复制到工作目录,或直接引用: ```python import sys, os sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'skills/cjk-viz/scripts')) from setup_cjk_font import setup_cjk_font font_name = setup_cjk_font() # 自动检测、配置、返回字体名 # 如果返回 None,说明系统无可用 CJK 字体,会打印警告 ``` 调用后 `plt.rcParams` 已经配置好,直接绘图即可。 ### 方式二:内联代码片段 如果不想引入外部文件,在脚本开头加入: ```python import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.font_manager as fm def _setup_cjk(): candidates = [ 'Noto Sans CJK SC', 'Noto Sans SC', 'Source Han Sans SC', 'WenQuanYi Micro Hei', 'WenQuanYi Zen Hei', 'Droid Sans Fallback', 'AR PL UMing CN', 'SimHei', 'Microsoft YaHei', 'PingFang SC', ] available = {f.name for f in fm.fontManager.ttflist} for name in candidates: if name in available: plt.rcParams['font.sans-serif'] = [name, 'DejaVu Sans'] plt.rcParams['axes.unicode_minus'] = False return name # 尝试从常见路径加载 .ttf search_paths = [ '/usr/share/fonts', '/usr/local/share/fonts', os.path.expanduser('~/.local/share/fonts'), os.path.join(os.path.dirname(__file__), 'fonts'), ] for base in
- 何时使用
- 快速使用
- 方式一:导入 helper(推荐)
- 方式二:内联代码片段
- 方式三:安装字体后再绘图
- 关键陷阱:.ttc 文件与 matplotlib
- 症状
- 解决方案:FontProperties 模式
- 优先级策略
- helper 脚本已内置此逻辑
- 字体优先级
- 与其他 skill 配合
- 验证
apt-get update && apt-get install -y fonts-noto-cjk pip install matplotlib-cjk-fonts
What does the cjk-viz skill do?
CJK (中日韩) 字体检测与 matplotlib 配置。任何涉及中文标签、标题、图例的 可视化任务启动前必须先执行本 skill 的字体检测流程,确保不会出现方块乱码。 适用于 matplotlib / seaborn / plotly 静态导出等场景。
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill cjk-viz --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
