Skip to content
Back to search

scipilot-figure-skill

SkillWorks with Claude CodeGitHub

SciPilot Skills 家族成员,负责科研数据可视化——但定位不是"画图工具", 而是"可视化顾问"。先做数据剖析(列类型/样本量/分布/异常值/分组结构/相关性), 再结合用户的论证目标推荐图型,主动拦截科研画图的经典错误(小样本画均值柱掩盖 分布、双 Y 轴、饼图、Y 轴不当截断、rainbow 色图、把分类点连成折线等),最后 产出 Nature / Science / IEEE / Elsevier / PNAS / 中文核心期刊级别的成图。 覆盖纯数据图:折线、柱状、散点、箱线 / 小提琴、热力图、误差棒、分布图(直方 图 / KDE)、相关性矩阵 / 散点矩阵、多面板组合。技术栈 matplotlib + seaborn + SciencePlots(静态)+ plotly(交互)。中英文双语,中文模式自动配置 Noto Sans CJK / Source Han Sans / SimHei 并修复负号方框,支持中文期刊"宋体正文 + Times New Roman 数字"混排。默认色盲安全配色 + 冗余编码 + 灰度预览。出图后做 "视觉自检闭环":渲染 PNG 预览→程序自检缺字/文字裁切/刻度重叠→AI 读图复核遮盖 与子图对齐→回改重渲,直到通过。 当用户的任务涉及以下任何情况时主动触发:论文配图、科研画图、数据可视化、 不知道用什么图、怎么展示数据、用什么图好、期刊投稿图、figure、出版级图表、 matplotlib、seaborn、plotly、误差棒、显著性标注、色盲安全配色、矢量图导出、 中文论文图表、多面板。**即使用户只是给一批数据问"这个怎么画"或"用什么图 好",也应使用本技能——本技能首要能力是"判断该用什么图",其次才是绘制。** 不做示意图、流程图、架构图。

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/haojae--scipilot-figure-skill/badge.svg)](/listings/haojae--scipilot-figure-skill)

HTML

<a href="/listings/haojae--scipilot-figure-skill"><img src="/api/listings/haojae--scipilot-figure-skill/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

请帮我安装这个 Skill:https://github.com/Haojae/scipilot-figure-skill.git

或手动:

git clone https://github.com/Haojae/scipilot-figure-skill.git \
          ~/.claude/skills/scipilot-figure-skill
pip install -r ~/.claude/skills/scipilot-figure-skill/requirements.txt

`SciencePlots` / `pypdf` / `kaleido` 是可选增强,缺失时不影响运行。

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 328 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. ---
  2. name: scipilot-figure-skill
  3. description: >-
  4. SciPilot Skills 家族成员,负责科研数据可视化——但定位不是"画图工具",
  5. 而是"可视化顾问"。先做数据剖析(列类型/样本量/分布/异常值/分组结构/相关性),
  6. 再结合用户的论证目标推荐图型,主动拦截科研画图的经典错误(小样本画均值柱掩盖
  7. 分布、双 Y 轴、饼图、Y 轴不当截断、rainbow 色图、把分类点连成折线等),最后
  8. 产出 Nature / Science / IEEE / Elsevier / PNAS / 中文核心期刊级别的成图。
  9. 覆盖纯数据图:折线、柱状、散点、箱线 / 小提琴、热力图、误差棒、分布图(直方
  10. 图 / KDE)、相关性矩阵 / 散点矩阵、多面板组合。技术栈 matplotlib + seaborn +
  11. SciencePlots(静态)+ plotly(交互)。中英文双语,中文模式自动配置 Noto Sans
  12. CJK / Source Han Sans / SimHei 并修复负号方框,支持中文期刊"宋体正文 +
  13. Times New Roman 数字"混排。默认色盲安全配色 + 冗余编码 + 灰度预览。出图后做
  14. "视觉自检闭环":渲染 PNG 预览→程序自检缺字/文字裁切/刻度重叠→AI 读图复核遮盖
  15. 与子图对齐→回改重渲,直到通过。
  16. 当用户的任务涉及以下任何情况时主动触发:论文配图、科研画图、数据可视化、
  17. 不知道用什么图、怎么展示数据、用什么图好、期刊投稿图、figure、出版级图表、
  18. matplotlib、seaborn、plotly、误差棒、显著性标注、色盲安全配色、矢量图导出、
  19. 中文论文图表、多面板。**即使用户只是给一批数据问"这个怎么画"或"用什么图
  20. 好",也应使用本技能——本技能首要能力是"判断该用什么图",其次才是绘制。**
  21. 不做示意图、流程图、架构图。
  22. ---
  23. # scipilot-figure-skill — 科研数据可视化顾问
  24. > SciPilot Skills 家族成员 | 从数据剖析到出版级成图
  25. ## 概述
  26. 科研工作者最大的画图痛点往往不是"不会用 matplotlib",而是"手上一堆数据,不知道该用什么图把结论讲清楚"。本技能的**首要能力是【思考与判断】**,其次才是【绘制】。
  27. 具体地——**永远先思考再画**:
  28. 1. 先理解数据再选图——拿到数据先做 EDA,用事实驱动图型选择
  29. 2. 先想清楚"这张图要论证什么"——同样数据,不同论点 = 不同图
  30. 3. 主动拦截科研画图的经典错误,而不是顺从
  31. 4. 维度太多就建议拆图,不硬塞
  32. **只覆盖纯数据图**:折线、柱状、散点、箱线/小提琴、热力图、误差棒、分布图、相关性矩阵、多面板组合。**不做**示意图、流程图、架构图。
  33. ## 何时使用
  34. - 用户给了一个 CSV / Excel / DataFrame 说"帮我画一下"或"用什么图好"
  35. - 用户在写论文要插数据图
  36. - 用户已有草图但说"达不到投稿要求"
  37. - 用户提到 Nature / Science / IEEE 等具体期刊
  38. - 用户问"中文论文 matplotlib 出方框怎么办"
  39. - 用户提到误差棒、显著性、色盲、矢量导出、多面板
  40. ## 核心工作流(8 步)
  41. **这是本技能与普通画图工具的根本区别——不能上来就画**。每一步缺位前一步的成果都不该执行。
  42. ### 第 0 步:理解任务
  43. 开画前**先搞清楚两件事**:
  44. 1. **这张图要论证什么观点 / 回答什么问题?** 同样数据,论点不同图就不同(详见 `references/chart_selection.md` 的"同一批数据、不同论点 → 不同图"小节)
  45. 2. **数据在哪里?长什么样?** 文件路径 / 字段含义 / 多少行 / 是否已经清洗
  46. **如果用户没说清论证目标**,主动问一句:"你这张图主要想说服读者相信什么?" 或从论文上下文推断并明确告诉用户你的假设。**不要默认"用户知道自己要什么"**。
  47. ### 第 1 步:剖析数据
  48. 调用 `scripts/profile_data.py`:
  49. ```bash
  50. python scripts/profile_data.py data.csv --group group --group condition
  51. ```
  52. 输出包含:每列类型、样本量、缺失率、连续列的描述统计 + 偏度 + 异常值、分组样本量分布、相关性矩阵、初步图型建议。
  53. 不会读这份报告?查 `references/data_profiling.md`。
  54. **重点核对**:
  55. - 列类型识别对不对?(数字 ID 被认成 ordinal 是常见误判)
  56. - 每组 n 是多少?小样本警告?
  57. - 是否高度偏态?是否需要对数轴?
  58. ### 第 2 步:选图
  59. **这是顾问职责的核心**。基于第 0、1 步的事实,查 `references/chart_selection.md` 的决策框架决定图型。要点:
  60. - **给出推荐 + 简短理由 + 1-2 个备选**(不要只丢一个选择给用户)
  61. - 如果数据维度过多(如分组组合 > 12)→ **明确建议拆图**,而不是硬塞
  62. - 如果用户指定的图型**不适合数据**(如 n=5 要画均值柱)→ **善意指出问题并说明更好的选择**,让用户决定。详见下方"主动拦截"小节
  63. - 如果数据特征意味着特殊处理(双峰分布、严重异常值、跨量级)→ 在选图建议里明确提及
  64. ### 第 3 步:查期刊规范
  65. 确定目标期刊后查 `references/journal_specs.md` 拿到:单/双栏宽(mm 与 inch)、字号、推荐字体、DPI、矢量格式偏好。
  66. 不知道目标期刊就问一句。"毕业论文 / 中文核心 / 英文 SCI / NeurIPS" 都对应不同规范。
  67. ### 第 4 步:配环境
  68. ```python
  69. from setup_style import setup_style
  70. setup_style(journal='nature', lang='en') # 英文 Nature
  71. setup_style(journal='general', lang='zh', serif_for_zh=True) # 中文宋体混排
  72. ```
  73. `SciencePlots` 装了自动用,没装回退到内置预设——不会因为缺它崩溃。
  74. ### 第 5 步:绘制
  75. 按 `references/plot_recipes.md` 对应章节的配方画。每节都有可直接复制的 Python 代码 + 常见坑。
  76. 画图时强制做到:
  77. - `figsize=(目标宽, 目标高)` 单位英寸——直接定最终尺寸
  78. - 用 `seaborn.color_palette('colorblind')` 或 Okabe-Ito + 冗余编码(不同线型/marker)
  79. - 误差棒 / 阴影要在图注交代是 SD / SEM / 95% CI + n
  80. ### 第 6 步:自检闭环(机器 + AI 读图)
  81. **三层都要过,缺一层都可能带病投稿**:
  82. 1. **语义层**:`references/viz_pitfalls.md` 18 条科研画图禁忌——图型/配色/误差是否踩坑
  83. 2. **形式层**:`references/publication_checklist.md` 形式合规(尺寸、DPI、字号、误差交代)
  84. 3. **视觉层(v2.1 新增)**:出图后**渲染 PNG → 程序自检 → AI 读图复核 → 回改**的闭环:
  85. - `visual_qa.render_preview(fig, 'figs/_preview.png')` 渲一张预览
  86. - `visual_qa.audit_layout(fig)` 程序抓**缺字乱码 / 文字裁切 / 刻度重叠**(确定性问题)
  87. - **用 `Read` 工具读这张 PNG**,对照 `references/visual_review.md` 的 8 项清单核对
  88. **图例压数据 / 子图标签对齐 / 配色灰度可分**(程序难判的感知问题)
  89. - 发现问题 → 按 `visual_review.md` 回改表改 → 重渲 → 再读,直到通过
  90. 任何一层不通过就回去改图。**矢量图的导出放在闭环通过之后**,把问题挡在投稿之前。
  91. ### 第 7 步:导出
  92. ```python
  93. from export_figure import export_figure
  94. export_figure(
  95. fig, basename='figs/fig1',
  96. formats=['pdf', 'svg', 'png'],
  97. size_inches=(3.5, 2.625),
  98. dpi=300,
  99. grayscale_preview=True, # 自动出灰度版供色盲检查
  100. )
  101. ```
  102. 最后跑一遍 `scripts/check_figure.py --strict` 机器审计。
  103. ## 选图速查(详细决策在 chart_selection.md)
  104. | 数据形态 | 推荐首选 | **不该用** |
  105. |---|---|---|
  106. | 1 个连续 看分布 | 直方图 + KDE / 箱线 | 饼图 |
  107. | 1 个分类 看占比 | 横向柱状(按值排序) | 饼图、3D 饼 |
  108. | 1 分类 + 1 连续,n<10/组 | **stripplot / dot plot**(直接列点) | 均值柱(**严禁**) |
  109. | 1 分类 + 1 连续,n≥10/组 | **箱线/小提琴 + stripplot 叠加** | 仅均值柱 |
  110. | 2 连续 看关系 | 散点 + 回归 + r 值 | 折线(除非 x 有序连续) |
  111. | 时间 / 剂量 vs 连续 | 折线 + 误差带 | 柱状 |
  112. | 多变量相关(>3 列)| 相关性热力图 / pairplot | 平行坐标 |
  113. | 矩阵数据 | 热力图(viridis/RdBu_r)| 3D 表面、rainbow 色图 |
  114. | 构成占比 | 堆叠柱 / treemap | **饼图** |
  115. 完整决策树和"同一数据不同论点 → 不同图"对照表见 `chart_selection.md`。
  116. ## 五条硬性原则
  117. ### 原则 1:按最终尺寸出图,不二次缩放
  118. `figsize` 直接设论文里实际尺寸(Nature 单栏 3.5 in、双栏 7.2 in;IEEE 单栏 3.5 in、双栏 7.16 in)。导出后**绝不在 Word / LaTeX 里再缩放**。
  119. **为什么**:matplotlib 字号是绝对单位(pt),Word 里缩 50% 9pt 就变 4.5pt——投稿前自检直接打回。
  120. ### 原则 2:矢量优先
  121. 折线 / 柱状 / 散点 / 热力(数据网格除外)/ 误差棒 → PDF / SVG / EPS。显微图、照片才用 TIFF / PNG(300-600 DPI)。**绝对不用 JPEG**。
  122. **为什么**:矢量任意缩放不糊,文字仍可选;JPEG 数据图边缘有压缩 artifact,期刊 PDF 检查器直接打回。
  123. ### 原则 3:配色对色盲友好
  124. 默认 `seaborn.color_palette('colorblind')` 或 Okabe-Ito。**同一张图不同类别加冗余编码**(线型 / marker)。出图前 `export_figure(..., grayscale_preview=True)` 看灰度版能否区分。
  125. **为什么**:约 8% 男性、0.5% 女性色觉异常。审稿人里有这群人,全靠红绿区分的图对他们传达力归零。
  126. ### 原则 4:字号在最终尺寸下可读
  127. 正文标签和刻度数字 7-9 pt,最小字 **≥ 6 pt**。
  128. **为什么**:审稿编辑会按 mm 打印查字号;<6 pt 不可读直接退回。
  129. ### 原则 5:误差必有交代
  130. 只要有误差棒 / 阴影区间 / 箱线——**图注必须写清**:
  131. - 误差类型(SD / SEM / 95% CI / IQR)
  132. - 样本量 n
  133. - 显著性检验方法 + 校正(如 Bonferroni)
  134. - 显著性符号定义(`* p<0.05` 等)
  135. **为什么**:SD 和 SEM 差一个 √n。混淆 = 结论反转 = 退稿。
  136. ## 主动拦截(顾问职责)
  137. 发现用户的需求会触发以下错误时,**先说明再给替代方案,不要默默照做**。完整 15 条详见 `references/viz_pitfalls.md`。
  138. | 错误 | 后果 | 替代方案 |
  139. |---|---|---|
  140. | n<10/组 还想画均值柱 | 掩盖分布、掩盖 n、审稿人怀疑 | 箱线 + stripplot;或直接 stripplot |
  141. | 双 Y 轴显示无关变量 | 视觉上的相关 / 分歧是作图者捏造的 | 拆成上下子图共享 x;或标准化共轴 |
  142. | 用饼图展示占比 | 人眼判角度差长度 3 倍 | 横向柱状(按值排序) |
  143. | 3D 柱 / 3D 饼 | 视角扭曲所有数值 | 2D 柱、热力图 |
  144. | 比例图 Y 轴不从 0 起 | 误导小差异看起来很大 | 从 0 起或用 log;或加明显断裂标记 |
  145. | 颜色映射连续值无 colorbar | 读者不知道深浅对应数值 | 必加 colorbar + 标 label/单位 |
  146. | x 是分类却用折线连均值 | 暗示不存在的连续关系 | 散点 / 点图 / 柱状 |
  147. | 一图塞 5 个论点 | 没论点 | 拆图,一张图一个核心结论 |
  148. | rainbow / jet 色图 | 感知不均匀、造假峰 | viridis / magma / RdBu_r |
  149. **拦截话术示例**:
  150. > 你要的"3 组各 5 个样本的均值柱状图"会触发 P1(均值柱掩盖分布):n=5 太小,柱状会让审稿人怀疑你藏了什么。我建议改成**箱线 + stripplot 叠加每个点**,5 个点直接可见、分布形态一目了然。要按原方案画吗?
  151. 尊重用户最终决定,但**留下明确的劝阻记录**。
  152. ## 中文支持
  153. 中文 matplotlib 出方框的根本原因:默认字体(DejaVu Sans 等)不含 CJK 字符表。`setup_style(lang='zh')` 自动做两件事:
  154. 1. 按优先级查中文字体:`Noto Sans CJK SC` > `Source Han Sans SC` > `SimHei` > `Microsoft YaHei`
  155. 2. 修负号方框:`plt.rcParams['axes.unicode_minus'] = False`
  156. 找不到任何 CJK 字体会抛清晰的安装提示(不会让你画完发现是方框)。
  157. **中文期刊的"宋体 + 数字 Times New Roman"混排**:传 `serif_for_zh=True`,优先选 Noto Serif CJK / Source Han Serif / SimSun。
  158. 详见 `references/journal_specs.md` 末尾的字体安装小节。
  159. ## 脚本说明
  160. | 脚本 | 干啥 | 主入口 |
  161. |---|---|---|
  162. | `profile_data.py` | EDA:列类型 / 样本量 / 分布 / 异常 / 相关 / 初步图型建议 | `profile_data(source, group_cols)` |
  163. | `setup_style.py` | 期刊预设 + CJK 字体配置 + SciencePlots 包装 | `setup_style(journal, lang, use_sciplots, serif_for_zh)` |
  164. | `export_figure.py` | 多格式 + 按最终尺寸 + 灰度预览 | `export_figure(fig, basename, formats, dpi, size_inches, grayscale_preview)` |
  165. | `check_figure.py` | 文件合规自检(格式 / DPI / 字体嵌入) | `check_figure(path, min_dpi, target_inches)` |
  166. | `layout_tools.py` | 子图标签对齐 + constrained/tight 兜底理版 | `add_panel_labels(fig, style)` / `finalize_figure(fig)` |
  167. | `visual_qa.py` | 渲染 PNG 预览 + 程序自检(缺字 / 裁切 / 刻度重叠) | `render_preview(fig, out)` / `audit_layout(fig)` |
  168. ## 参考文档
  169. `references/` 下七份文档——**按需 view,不要一次全读**:
  170. | 文档 | 何时读 |
  171. |---|---|
  172. | `chart_selection.md` | **每次选图必读**——决策框架、不同论点→不同图 |
  173. | `data_profiling.md` | 读不懂 `profile_data.py` 输出 |
  174. | `viz_pitfalls.md` | 自检前必读——18 条避坑清单(含 P16-18 排版/渲染坑) |
  175. | `journal_specs.md` | 不确定目标期刊的栏宽/字号/DPI/字体 |
  176. | `plot_recipes.md` | 9 类图各自的完整配方 + 适用场景 |
  177. | `publication_checklist.md` | 投稿前最后过形式合规清单 |
  178. | `visual_review.md` | 出图后视觉自检——AI 读图 8 项清单 + 回改循环协议 |
  179. 每份开头都有目录——先查目录定位,再 view 对应小节。
  180. ## 常见任务示例
  181. ### 任务 A:用户只丢一个 CSV 说"帮我把这个画成论文图"
  182. **思考-绘制工作流的范例**:
  183. 1. **第 0 步**:问用户"你这份数据主要想说服读者相信什么?"——是组间差异?时间趋势?变量关系?
  184. 2. **第 1 步**:跑 `python scripts/profile_data.py data.csv` 得到剖析报告
  185. 3. **第 2 步**:读报告里"列类型 + 样本量 + 分组结构",结合用户的论证目标查 `chart_selection.md` 决策。**主动给出推荐 + 理由 + 1-2 备选**
  186. 4. **拿到用户确认后**进入第 3-7 步:查期刊规范、配环境、画、自检、导出
  187. 不要跳过任何一步。
  188. ### 任务 B:用户说"我想用柱状图展示三组各 5 个样本的均值"
  189. **主动拦截的范例**:
  190. ```
  191. 你要的"三组各 5 个样本均值柱状图"会触发科研画图的经典 P1 错误
  192. (参见 viz_pitfalls.md)——n=5 太小,柱状图的高度 + 一根误差棒无法
  193. 告诉读者数据真实分布。审稿人看到很可能要求"show individual data points"。
  194. 我建议改成 **箱线图 + stripplot 叠加每个点**:5 个点直接可见,
  195. 不掩盖任何信息,反而更可信。代码也只多一行。
  196. 要按原方案画,还是改成箱线+stripplot?
  197. ```
  198. 如果用户坚持要柱状,那也照做——但**至少**强制叠加 stripplot 显示每个点。
  199. ### 任务 C:多面板组合图
  200. 用户:"给我画一个 Figure 1:4 个 panel,分别是 PCA、loss 曲线、混淆矩阵、生存曲线。"
  201. 流程:
  202. 1. 确认目标期刊(决定整张图 7.2 in 还是 7.16 in;Nature `a/b/c` vs IEEE `(a)(b)(c)`)
  203. 2. 各 panel 独立画,**保证字号、配色、坐标尺度统一**(同一变量在 4 个 panel 里同色)
  204. 3. 用 `plt.subplots(2, 2, figsize=(7.2, 5.4))` 组合(`setup_style` 已默认开 constrained_layout)
  205. 4. `layout_tools.finalize_figure(fig)` 理顺版面,再 `add_panel_labels(fig, style='nature')` 打 a/b/c/d——**统一 figure 坐标自动横竖对齐**,不要手摆 `ax.text`(易错位,见 viz_pitfalls P18;IEEE 用 `style='ieee'` → (a)(b)(c))
  206. 5. **视觉自检闭环**:`render_preview` 渲 PNG → `audit_layout` 程序自检 → `Read` 读图核对子图对齐/遮盖 → 回改 → 通过后再导出 + 灰度检查
  207. 详细配方见 `plot_recipes.md` 第 9 节。
  208. ### 任务 D:带显著性标注的统计图
  209. 用户:"3 组数据,箱线图加显著性标注。"
  210. 流程:
  211. 1. profile 确认 n(n<10 → 必须叠 stripplot)
  212. 2. 跑统计检验(**用户必须告知**用了什么检验,是否多重比较校正)
  213. 3. 画箱线 + stripplot
  214. 4. 用 `matplotlib.lines.Line2D` 或 `statannotations` 在组之间画显著性桥
  215. 5. **图注必须写**:误差类型 / n / 检验方法 / 校正 / 符号含义
  216. 配方见 `plot_recipes.md` 第 4 节。
  217. ## 依赖
  218. ```
  219. matplotlib>=3.7
  220. seaborn>=0.13
  221. plotly>=5.18
  222. pandas>=2.0
  223. numpy>=1.24
  224. scipy>=1.10 # profile_data 的偏度计算用到
  225. Pillow>=10.0 # check_figure / grayscale preview
  226. SciencePlots>=2.1 # 可选;装了样式更接近期刊
  227. pypdf>=4.0 # 可选;check_figure 字体嵌入检查
  228. kaleido>=0.2.1 # 可选;plotly 导出 PDF/PNG
  229. ```
  230. 可选依赖缺失时本技能仍能跑——会优雅降级并提示。
README.md · README · 357 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # scipilot-figure-skill
  2. > SciPilot Skills family. Scientific data **visualization advisor** — thinks first, plots second.
  3. > SciPilot Skills 家族成员 — 科研数据**可视化顾问**,先思考后绘制。
  4. [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
  5. [![Python: 3.9+](https://img.shields.io/badge/Python-3.9%2B-3776AB.svg)](#dependencies--依赖)
  6. [![Status: v2.1.0](https://img.shields.io/badge/Status-v2.1.0-success.svg)](#)
  7. [![Advisor Mode](https://img.shields.io/badge/Mode-Advisor%2BPlotter-c41e3a.svg)](#为什么这不只是个画图工具)
  8. [![Stack](https://img.shields.io/badge/Stack-matplotlib%20%7C%20seaborn%20%7C%20plotly-orange.svg)](#)
  9. [![Claude Code Skill](https://img.shields.io/badge/Claude%20Code-Skill-orange.svg)](https://claude.com/claude-code)
  10. A [Claude Code](https://claude.com/claude-code) / [Codex](https://github.com/openai/codex) / Cursor Skill that does **two things in order**: (1) profiles your data and recommends the right chart for the argument you want to make, (2) renders it at publication grade for Nature / Science / IEEE / Elsevier / PNAS / Chinese journals. Built on **matplotlib + seaborn + SciencePlots** (static) and **plotly** (interactive), with **CJK font auto-configuration** so Chinese text never renders as boxes.
  11. > [中文文档](#中文文档) | [English](#english)
  12. ---
  13. ## 中文文档
  14. ### 概览
  15. 科研工作者最大的画图痛点往往不是"不会用 matplotlib",而是"手上一堆数据,不知道该用什么图把结论讲清楚"。`scipilot-figure-skill` 是 SciPilot Skills 家族的第二个成员,专做这件事——
  16. **它的首要能力是【思考与判断】,其次才是【绘制】。**
  17. ### 为什么这不只是个画图工具
  18. ```
  19. 普通画图工具 scipilot-figure-skill
  20. ───────────── ─────────────────────
  21. 你说 "画柱状图" → 先 EDA:每列类型、样本量、分布、异常值、相关性
  22. 直接 plt.bar() 再问:"你想论证什么?组间差异?关系?趋势?"
  23. 按数据特征 + 论证目标查决策框架推荐图型
  24. n=5 想画均值柱时主动拦截 → 改用 stripplot
  25. 维度 > 12 时建议拆图,不硬塞
  26. 最后才进入绘制 → 期刊规范 → 自检 → 导出
  27. ```
  28. ### 核心工作流(8 步)
  29. ```
  30. 0. 理解任务 ── 这张图要论证什么?数据在哪?
  31. ↓
  32. 1. 剖析数据 ── profile_data.py:列类型/样本量/分布/异常/相关
  33. ↓
  34. 2. 选图 ── chart_selection.md:按数据形态+论证目标决策
  35. ↓ (主动拦截 → viz_pitfalls.md)
  36. 3. 查规范 ── journal_specs.md:栏宽/字号/DPI/字体
  37. ↓
  38. 4. 配环境 ── setup_style.py:期刊预设+CJK字体
  39. ↓
  40. 5. 绘制 ── plot_recipes.md:9 类图配方
  41. ↓
  42. 6. 自检闭环 ── 程序自检 visual_qa + AI 读图 visual_review.md(缺字/裁切/重叠/对齐→回改)
  43. ↓
  44. 7. 导出 ── export_figure.py:多格式+按最终尺寸+灰度预览
  45. ```
  46. ### v2.1 新增:出图后的视觉自检闭环
  47. 普通画图工具画完就结束——没人回看成图,于是中文方框、文字被裁、图例压数据、子图编号乱放,全留到投稿才暴露。v2.1 补上**出图后的闭环**:
  48. ```
  49. 绘制 → 渲染 PNG → 程序自检(缺字/裁切/重叠) + AI 读图(遮盖/子图对齐/灰度)
  50. ↓ 发现问题
  51. 回到对应步骤改图 → 重渲 → 再读,直到通过
  52. ```
  53. - **程序抓确定性问题**:`visual_qa.audit_layout()` 同时盯 warning + logging 两条通道拦截缺字乱码,并查文字越界裁切、刻度标签重叠。
  54. - **AI 读图抓感知性问题**:渲成 PNG 后用多模态读图能力核对图例是否压数据、子图 a/b/c 是否对齐、配色灰度可分——这些程序查不出。
  55. - **子图标签一行对齐**:`layout_tools.add_panel_labels(fig)` 用统一 figure 坐标让 a/b/c/d 横竖成线,不再手摆易错位。
  56. - **字体兜底**:`setup_style` 全模式默认修负号方框 + 自动配 CJK 字体,从源头少出乱码。
  57. 详见 [`references/visual_review.md`](references/visual_review.md)。
  58. ### 五条硬性原则
  59. 1. **按最终尺寸出图不二次缩放** — `figsize=(3.5, 2.625)` 直接定 Nature 单栏
  60. 2. **矢量优先** — 数据图走 PDF / SVG / EPS;照片才用 TIFF/PNG;**绝不 JPEG**
  61. 3. **配色对色盲友好** — 默认 Okabe-Ito,加冗余编码,出图前查灰度
  62. 4. **字号在最终尺寸下可读** — 7-9 pt,最小 6 pt
  63. 5. **误差必有交代** — 图注必须写清 SD/SEM/95%CI + n + 检验方法
  64. ### 主动拦截的画图错误(精选)
  65. 完整 15 条在 [`references/viz_pitfalls.md`](references/viz_pitfalls.md)。
  66. - **P1**:n<10/组的均值柱掩盖分布 → 改箱线 + stripplot
  67. - **P2**:双 Y 轴的"相关"是作图者捏造的 → 拆子图或标准化
  68. - **P3**:饼图与 3D 图 → 横向柱状
  69. - **P4**:Y 轴不当截断 → 从 0 起或断裂明示
  70. - **P6**:x 是分类用折线连均值 → 散点 / 柱状
  71. - **P14**:rainbow / jet 色图 → viridis / RdBu_r
  72. - **P12**:一图多论点 → 拆图,一图一结论
  73. - **P16**:中文/负号变方框 → setup_style 配 CJK + 关 unicode_minus,导出前 visual_qa 拦截
  74. - **P18**:子图 a/b/c 乱放 → add_panel_labels 统一对齐
  75. ### 安装
  76. ```
  77. 请帮我安装这个 Skill:https://github.com/Haojae/scipilot-figure-skill.git
  78. ```
  79. 或手动:
  80. ```bash
  81. git clone https://github.com/Haojae/scipilot-figure-skill.git \
  82. ~/.claude/skills/scipilot-figure-skill
  83. pip install -r ~/.claude/skills/scipilot-figure-skill/requirements.txt
  84. ```
  85. `SciencePlots` / `pypdf` / `kaleido` 是可选增强,缺失时不影响运行。
  86. ### 中文支持
  87. `setup_style(lang='zh')` 按优先级查找:
  88. ```
  89. Noto Sans CJK SC > Source Han Sans SC > SimHei > Microsoft YaHei
  90. ```
  91. 找不到任何 CJK 字体时抛出清晰的安装提示。中文期刊"宋体 + Times New Roman 数字"混排:传 `serif_for_zh=True`。
  92. ### 使用示例(4 个,**至少 2 个体现"思考"**)
  93. **例 1:用户只丢一个 CSV**
  94. ```
  95. 我有这份 results.csv,帮我画成论文图。
  96. ```
  97. → Skill 不会直接画。会先:
  98. 1. 问"你这份数据主要想说服读者相信什么?"
  99. 2. 跑 `profile_data.py` 输出剖析报告
  100. 3. 给出推荐图型 + 理由 + 备选
  101. 4. 用户确认后才进入绘制流程
  102. **例 2:用户指定的图型不合适**
  103. ```
  104. 帮我画 3 组各 5 个样本的均值柱状图。
  105. ```
  106. → Skill 主动拦截:
  107. > n=5 太小,均值柱掩盖分布——审稿人很可能要求"show individual points"。
  108. > 我建议改成 **箱线 + stripplot 叠加每个点**:5 个点直接可见。要按原方案画,还是改?
  109. **例 3:多面板组合**
  110. ```
  111. 给我画 Figure 1:4 panel,分别是 PCA、loss、混淆矩阵、生存曲线。
  112. Nature 双栏。
  113. ```
  114. → 各 panel 字号配色统一,子图标签 a/b/c/d 加粗左上,导出 PDF + 灰度预览。
  115. **例 4:带显著性标注**
  116. ```
  117. 3 组数据画箱线 + 显著性。
  118. ```
  119. → 先确认 n、检验方法、是否多重校正;图注必须写清统计内容。
  120. ### 命令行直接调脚本
  121. ```bash
  122. # 数据剖析(思考的起点)
  123. python scripts/profile_data.py results.csv --group group --group condition
  124. # 列可用 CJK 字体
  125. python scripts/setup_style.py --list-fonts
  126. # 演示导出
  127. python scripts/export_figure.py demo --out ./test_demo
  128. # 合规自检
  129. python scripts/check_figure.py figs/*.pdf --min-dpi 300 --strict
  130. ```
  131. ### SciPilot Skills 家族
  132. | Skill | 状态 | 功能 |
  133. |---|---|---|
  134. | scipilot-cite-skill | [v1.0.0](https://github.com/Haojae/scipilot-cite-skill) | 文献检索与引用插入 |
  135. | **scipilot-figure-skill** | **v2.1.0 (本仓库)** | **可视化顾问 + 绘制 + 视觉自检闭环** |
  136. | scipilot-writing-skill | [v1.0.0](https://github.com/Haojae/scipilot-writing-skill) | 学术写作与润色 |
  137. | scipilot-review-skill | 规划中 | AI 模拟审稿 |
  138. | scipilot-submit-skill | 规划中 | 投稿格式适配 |
  139. | scipilot-read-skill | 规划中 | 论文阅读与翻译 |
  140. ### 许可证
  141. [MIT](LICENSE) © 2026 Haojae
  142. ---
  143. ## English
  144. ### Overview
  145. The hardest part of scientific plotting is rarely "I don't know matplotlib" — it's "I have data, I don't know which chart conveys my conclusion." `scipilot-figure-skill` is the second member of the SciPilot Skills family, built around this insight: **think first, plot second**.
  146. ### Why this isn't just a plotting tool
  147. ```
  148. Generic plotter scipilot-figure-skill
  149. ────────────── ──────────────────────
  150. "plot a bar chart" → Profiles data first: types, n, distribution, outliers
  151. plt.bar() Asks: "What argument do you want this figure to make?"
  152. Decides chart type from data shape + intent
  153. Refuses bad choices (n=5 mean bar → stripplot instead)
  154. Suggests splitting figures when dimensions exceed 12
  155. Only then renders → spec → audit → export
  156. ```
  157. ### 8-step core workflow
  158. ```
  159. 0. Understand — what does this figure argue? where is the data?
  160. ↓
  161. 1. Profile — profile_data.py: types / n / distribution / outliers / corr
  162. ↓
  163. 2. Select — chart_selection.md: decision framework by shape + intent
  164. ↓ (active interception → viz_pitfalls.md)
  165. 3. Spec — journal_specs.md: column width / font / DPI
  166. ↓
  167. 4. Style — setup_style.py: journal preset + CJK font config
  168. ↓
  169. 5. Plot — plot_recipes.md: 9 recipe families
  170. ↓
  171. 6. Self-check — visual_qa (program) + AI reads the PNG (visual_review.md): glyphs/clipping/overlap/alignment
  172. ↓
  173. 7. Export — export_figure.py: multi-format + final size + grayscale
  174. ```
  175. ### New in v2.1: a post-render visual self-check loop
  176. Generic plotters stop at "saved" — nobody looks at the result, so CJK tofu boxes, clipped labels, legends covering data, and misaligned panel letters all survive to submission. v2.1 closes the loop **after rendering**:
  177. ```
  178. plot → render PNG → program audit (glyphs/clipping/overlap) + AI reads image (occlusion/panel alignment/grayscale)
  179. ↓ issues found
  180. go back, fix, re-render, re-read — until clean
  181. ```
  182. - **Program catches deterministic issues**: `visual_qa.audit_layout()` traps missing-glyph warnings (both warnings and logging channels), text clipped off-canvas, and overlapping tick labels.
  183. - **AI catches perceptual issues**: after rasterizing to PNG, the skill reads the image to check whether the legend covers data, whether panel letters a/b/c line up, and whether colors stay distinct in grayscale.
  184. - **One-call panel alignment**: `layout_tools.add_panel_labels(fig)` places a/b/c/d in unified figure coordinates so they align both ways.
  185. - **Font safety net**: `setup_style` fixes the minus-sign box in all modes and auto-configures CJK fonts.
  186. See [`references/visual_review.md`](references/visual_review.md).
  187. ### Five hard rules
  188. 1. **Render at final size, never rescale** — set `figsize=(3.5, 2.625)` directly
  189. 2. **Vectors first** — PDF / SVG / EPS for data figures; **never JPEG**
  190. 3. **Colorblind-safe palette** — Okabe-Ito default + redundant encoding
  191. 4. **Readable type at final size** — 7-9 pt body, 6 pt minimum
  192. 5. **Errors must be explained** — captions state SD/SEM/CI + n + test type
  193. ### Actively intercepted mistakes
  194. Full 15 in [`references/viz_pitfalls.md`](references/viz_pitfalls.md).
  195. - **P1**: mean-only bar charts with n<10 hide distributions → use box + stripplot
  196. - **P2**: dual-Y axis fabricates correlations → split panels or standardize
  197. - **P3**: pie charts and 3D bars → horizontal bar
  198. - **P14**: rainbow / jet colormaps → viridis / RdBu_r
  199. - **P12**: one figure with five points → split, one figure per claim
  200. - **P16**: CJK / minus-sign tofu boxes → setup_style configures CJK + disables unicode_minus; visual_qa blocks leftover missing glyphs
  201. - **P18**: scattered panel letters → add_panel_labels aligns a/b/c in one call
  202. ### Installation
  203. ```
  204. Please install this Skill for me: https://github.com/Haojae/scipilot-figure-skill.git
  205. ```
  206. Manual:
  207. ```bash
  208. git clone https://github.com/Haojae/scipilot-figure-skill.git \
  209. ~/.claude/skills/scipilot-figure-skill
  210. pip install -r ~/.claude/skills/scipilot-figure-skill/requirements.txt
  211. ```
  212. ### Usage examples
  213. **Example 1: bare CSV**
  214. ```
  215. I have results.csv. Plot it for my paper.
  216. ```
  217. The skill will: profile the data, ask what argument the figure should make, recommend a chart with rationale + alternatives, and only then plot.
  218. **Example 2: bad request, gentle refusal**
  219. ```
  220. Plot a bar chart of group means: 3 groups, 5 samples each.
  221. ```
  222. The skill will reply:
  223. > With n=5 per group a mean bar chart hides the distribution and reviewers
  224. > typically ask for individual data points. I recommend **box plot +
  225. > stripplot overlay** — all five points are visible and the distribution
  226. > is clear. Stick with bars, or switch?
  227. **Example 3: multi-panel composite**
  228. ```
  229. Figure 1, 4 panels: PCA, loss curves, confusion matrix, survival.
  230. Nature double column.
  231. ```
  232. **Example 4: statistical comparison**
  233. ```
  234. 3 groups, box plot with significance.
  235. ```
  236. ### SciPilot Skills family
  237. | Skill | Status | Purpose |
  238. |---|---|---|
  239. | scipilot-cite-skill | [v1.0.0](https://github.com/Haojae/scipilot-cite-skill) | Reference discovery & insertion |
  240. | **scipilot-figure-skill** | **v2.1.0 (this repo)** | **Advisor + renderer + visual self-check loop** |
  241. | scipilot-writing-skill | [v1.0.0](https://github.com/Haojae/scipilot-writing-skill) | Writing & polishing |
  242. | scipilot-review-skill | Planned | AI peer-review simulation |
  243. | scipilot-submit-skill | Planned | Submission formatting |
  244. | scipilot-read-skill | Planned | Paper reading & translation |
  245. ### License
  246. [MIT](LICENSE) © 2026 Haojae
  247. ### Dependencies / 依赖
  248. ```
  249. matplotlib>=3.7
  250. seaborn>=0.13
  251. plotly>=5.18
  252. pandas>=2.0
  253. numpy>=1.24
  254. scipy>=1.10
  255. Pillow>=10.0
  256. SciencePlots>=2.1 # optional
  257. pypdf>=4.0 # optional
  258. kaleido>=0.2.1 # optional
  259. PyMuPDF>=1.23 # optional; only for visual_qa.render_preview() of saved PDFs
  260. ```
  261. Python 3.9+ recommended.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.