figure-generation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scientific Figure Generation

科研图表生成

Generate publication-quality figures for research papers.
为研究论文生成达到出版级别的图表。

Input

输入

  • $0
    — Description of the desired figure
  • $1
    — (Optional) Path to data file (CSV, JSON, NPY, PKL) or results directory
  • $0
    — 所需图表的描述
  • $1
    —(可选)数据文件路径(CSV、JSON、NPY、PKL格式)或结果目录

Scripts

脚本

Generate figure template

生成图表模板

bash
python ~/.claude/skills/figure-generation/scripts/figure_template.py --type bar --output figure_script.py --name comparison
python ~/.claude/skills/figure-generation/scripts/figure_template.py --list-types
Available types:
bar
,
training-curve
,
heatmap
,
ablation
,
line
,
scatter
,
radar
,
violin
,
tsne
,
attention
bash
python ~/.claude/skills/figure-generation/scripts/figure_template.py --type bar --output figure_script.py --name comparison
python ~/.claude/skills/figure-generation/scripts/figure_template.py --list-types
支持的类型:
bar
training-curve
heatmap
ablation
line
scatter
radar
violin
tsne
attention

Three-Phase Pipeline (from MatPlotAgent)

三阶段流程(来自MatPlotAgent)

Phase 1: Query Expansion

阶段1:查询扩展

Expand the user's figure description into step-by-step coding specifications using the prompts in
references/figure-prompts.md
. Determine: figure type, data mapping (x/y/color/hue), style requirements, paper conventions.
使用
references/figure-prompts.md
中的提示词,将用户的图表描述扩展为分步编码规范。确定:图表类型、数据映射(x/y/颜色/色调)、样式要求、论文格式规范。

Phase 2: Code Generation with Execution Loop (up to 4 retries)

阶段2:带执行循环的代码生成(最多4次重试)

  1. Generate a self-contained Python script using the template from
    scripts/figure_template.py
    as a starting point
  2. Write script to a temp file and execute:
    python figure_script.py
  3. If error: capture traceback, feed back, regenerate (see ERROR_PROMPT in references)
  4. If no
    .png
    produced: add explicit save instruction, retry
  5. On success: report the generated figure path
  1. scripts/figure_template.py
    中的模板为基础,生成一个独立的Python脚本
  2. 将脚本写入临时文件并执行:
    python figure_script.py
  3. 若出现错误:捕获回溯信息,反馈后重新生成(参考references中的ERROR_PROMPT)
  4. 若未生成
    .png
    文件:添加显式保存指令,重试
  5. 执行成功:报告生成的图表路径

Phase 3: Visual Refinement

阶段3:视觉优化

Read the generated PNG file and visually inspect using the VLM feedback prompts from
references/figure-prompts.md
:
  • Does the figure type match the request?
  • Are labels, titles, and legends correct?
  • Is the color scheme appropriate and consistent?
  • Are axis scales sensible? Is text readable at publication size?
If improvements needed: generate corrective instructions and re-execute.
读取生成的PNG文件,使用
references/figure-prompts.md
中的VLM反馈提示词进行视觉检查:
  • 图表类型是否符合需求?
  • 标签、标题和图例是否正确?
  • 配色方案是否合适且一致?
  • 坐标轴刻度是否合理?在出版尺寸下文本是否清晰可读?
若需要改进:生成修正指令并重新执行。

References

参考资料

  • All MatPlotAgent prompts:
    ~/.claude/skills/figure-generation/references/figure-prompts.md
  • Figure templates:
    ~/.claude/skills/figure-generation/scripts/figure_template.py
  • 所有MatPlotAgent提示词:
    ~/.claude/skills/figure-generation/references/figure-prompts.md
  • 图表模板:
    ~/.claude/skills/figure-generation/scripts/figure_template.py

Output

输出

Both PNG (preview, 300 DPI) and PDF (vector, for paper) formats. Plus the LaTeX include code:
latex
\begin{figure}[t]
    \centering
    \includegraphics[width=\linewidth]{figures/figure_name.pdf}
    \caption{Description. Best viewed in color.}
    \label{fig:figure_name}
\end{figure}
同时提供PNG(预览用,300 DPI)和PDF(矢量格式,用于论文)两种格式。此外还包含LaTeX引用代码:
latex
\begin{figure}[t]
    \centering
    \includegraphics[width=\linewidth]{figures/figure_name.pdf}
    \caption{Description. Best viewed in color.}
    \label{fig:figure_name}
\end{figure}

Quality Requirements

质量要求

  • DPI ≥ 300, or vector PDF
  • Colorblind-friendly palette (no red-green only)
  • All text ≥ 8pt at print size
  • Consistent styling across all paper figures
  • No matplotlib default title — use LaTeX caption
  • DPI ≥ 300,或使用矢量PDF格式
  • 适合色觉障碍人群的配色方案(避免仅使用红绿色)
  • 所有文本在打印尺寸下≥8pt
  • 论文中所有图表样式保持一致
  • 不使用matplotlib默认标题——改用LaTeX标题

Related Skills

相关技能

  • Upstream: data-analysis, experiment-code
  • Downstream: paper-writing-section, paper-compilation, slide-generation
  • See also: table-generation
  • 上游:data-analysis, experiment-code
  • 下游:paper-writing-section, paper-compilation, slide-generation
  • 另见:table-generation