mcpField
S
scientific-schematics

scientific-schematics

github.com/davila7创意与媒体33.0k1.2k 次安装今天更新
代码仓库

关于 scientific-schematics

scientific-schematics 是用于生成科学示意图的技能,用户以自然语言描述图示后,由 Nano Banana Pro 生成图像,并由 Gemini 3 Pro 按文档类型评估,必要时迭代改进。

主要功能

  1. 01根据自然语言描述生成示意图
  2. 02Gemini 3 Pro 评估图像质量
  3. 03按文档类型设置质量阈值
  4. 04低于阈值时改进提示词并重生成
  5. 05保存版本图像与评审日志

适用场景

  1. 01制作论文中的研究流程图
  2. 02绘制神经网络架构图
  3. 03展示生物通路或电路示意图
  4. 04生成演示文稿或海报中的技术图

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davila7/claude-code-templates --skill scientific-schematics

安装后在 Claude Code 中输入/scientific-schematics确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

example_usage.sh
QUICK_REFERENCE.md
README.md
test_ai_generation.py
references/
best_practices.md
scripts/
generate_schematic_ai.py
generate_schematic.py

详细介绍

科学示意图与图表

概述

科学示意图与图表将复杂概念转化为清晰的视觉呈现,便于发表。此技能使用 Nano Banana Pro AI 生成图表,并由 Gemini 3 Pro 进行质量审查。

工作原理:

  • 用自然语言描述图表
  • Nano Banana Pro 自动生成可用于发表的高质量图像
  • Gemini 3 Pro 根据文档类型的阈值审查质量
  • 智能迭代:仅在质量低于阈值时重新生成
  • 几分钟内即可获得可用于发表的成品
  • 无需编写代码、使用模板或手动绘制

不同文档类型的质量阈值:

文档类型阈值说明
期刊8.5/10Nature、Science、同行评审期刊
会议8.0/10会议论文
学位论文8.0/10博士论文、学位论文
资助申请8.0/10资助申请书
预印本7.5/10arXiv、bioRxiv 等
报告7.5/10技术报告
海报7.0/10学术海报
演示文稿6.5/10幻灯片、演讲
默认7.5/10通用

只需描述你的需求,Nano Banana Pro 就会为你创建图表。 所有图表都会存储在 figures/ 子文件夹中,并在论文/海报中引用。

快速入门:生成任意图表

只需描述图表,即可创建任意科学图表。Nano Banana Pro 会通过智能迭代自动处理所有内容:

# Generate for journal paper (highest quality threshold: 8.5/10)
python scripts/generate_schematic.py "CONSORT participant flow diagram with 500 screened, 150 excluded, 350 randomized" -o figures/consort.png --doc-type journal

# Generate for presentation (lower threshold: 6.5/10 - faster)
python scripts/generate_schematic.py "Transformer encoder-decoder architecture showing multi-head attention" -o figures/transformer.png --doc-type presentation

# Generate for poster (moderate threshold: 7.0/10)
python scripts/generate_schematic.py "MAPK signaling pathway from EGFR to gene transcription" -o figures/mapk_pathway.png --doc-type poster

# Custom max iterations (max 2)
python scripts/generate_schematic.py "Complex circuit diagram with op-amp, resistors, and capacitors" -o figures/circuit.png --iterations 2 --doc-type journal

后台处理过程:

  1. 第 1 次生成:Nano Banana Pro 遵循科学图表最佳实践,创建初始图像
  2. 第 1 次审查:Gemini 3 Pro 根据文档类型阈值评估质量
  3. 决策:如果质量 >= 阈值 → 完成(无需进一步迭代!)
  4. 如果低于阈值:根据评审意见改进提示词,然后重新生成
  5. 重复:直到质量达到阈值,或达到最大迭代次数

智能迭代的优势:

  • ✅ 如果首次生成的质量已足够,可节省 API 调用
  • ✅ 期刊论文采用更高的质量标准
  • ✅ 加快演示文稿/海报的交付速度
  • ✅ 为每种使用场景提供适当的质量

输出:带版本号的图像,以及包含质量评分、评审意见和提前停止信息的详细审查日志。

配置

设置你的 OpenRouter API 密钥:

export OPENROUTER_API_KEY='your_api_key_here'

在此获取 API 密钥:https://openrouter.ai/keys

AI 生成最佳实践

科学图表的有效提示词:

✓ 好的提示词(具体、详尽):

  • “CONSORT 流程图,展示参与者从筛查(n=500)到随机分组,再到最终分析的流程”
  • “Transformer 神经网络架构,左侧为编码器堆栈,右侧为解码器堆栈,展示多头注意力和交叉注意力连接”
  • “生物信号级联:EGFR 受体 → RAS → RAF → MEK → ERK → 细胞核,并标注磷酸化步骤”
  • “IoT 系统框图:传感器 → 微控制器 → WiFi 模块 → 云服务 → 移动应用”

✗ 避免含糊的提示词:

  • “画一个流程图”(过于笼统)
  • “神经网络”(哪种类型?包含哪些组件?)
  • “通路图”(哪条通路?涉及哪些分子?)

应包含的关键要素:

  • 类型:流程图、架构图、通路图、电路图等
  • 组件:要包含的具体元素
  • 流程/方向:元素如何连接(从左到右、从上到下)
  • 标签:要包含的关键注释或文字
  • 风格:任何特定的视觉要求

科学质量指南(自动应用):

  • 简洁的白色/浅色背景
  • 高对比度,便于阅读
  • 清晰易读的标签(最小 10pt)
  • 专业的字体排版(无衬线字体)
  • 色盲友好配色(Okabe-Ito 调色板)
  • 合理留白,避免拥挤
  • 适当添加比例尺、图例和坐标轴

适用场景

在以下情况下使用此技能:

  • 创建神经网络架构图(Transformer、CNN、RNN 等)
  • 绘制系统架构图和数据流图
  • 绘制研究设计方法流程图(CONSORT、PRISMA)
  • 可视化算法工作流和处理管线
  • 创建电路图和电气原理图
  • 描绘生物通路和分子相互作用
  • 生成网络拓扑和层次结构
  • 展示概念框架和理论模型
  • 为技术论文设计框图

使用方法

只需用自然语言描述你的图表。 Nano Banana Pro 会自动生成:

python scripts/generate_schematic.py "your diagram description" -o output.png

就是这么简单! AI 会处理:

  • ✓ 布局和构图
  • ✓ 标签和注释
  • ✓ 颜色和样式
  • ✓ 质量审核和优化
  • ✓ 可直接用于出版的输出

适用于所有图表类型:

  • 流程图(CONSORT、PRISMA 等)
  • 神经网络架构图
  • 生物通路图
  • 电路图
  • 系统架构图
  • 框图
  • 任何科学可视化图表

无需编写代码、套用模板或手动绘图。


AI 生成模式(Nano Banana Pro + Gemini 3 Pro 审核)

智能迭代优化工作流

AI 生成系统采用智能迭代——只有当质量低于对应文档类型的阈值时才会重新生成:

智能迭代的工作方式
┌─────────────────────────────────────────────────────┐
│  1. Generate image with Nano Banana Pro             │
│                    ↓                                │
│  2. Review quality with Gemini 3 Pro                │
│                    ↓                                │
│  3. Score >= threshold?                             │
│       YES → DONE! (early stop)                      │
│       NO  → Improve prompt, go to step 1            │
│                    ↓                                │
│  4. Repeat until quality met OR max iterations      │
└─────────────────────────────────────────────────────┘
第 1 次迭代:初始生成

提示词构建:

Scientific diagram guidelines + User request

输出: diagram_v1.png

Gemini 3 Pro 质量审核

Gemini 3 Pro 会从以下方面评估图表:

  1. 科学准确性(0-2 分)——概念、标注和关系是否正确
  2. 清晰度和可读性(0-2 分)——是否易于理解、层次是否清晰
  3. 标签质量(0-2 分)——标签是否完整、易读且一致
  4. 布局和构图(0-2 分)——流程是否合理、布局是否均衡、是否存在重叠
  5. 专业外观(0-2 分)——质量是否达到可直接用于出版的水平

审核输出示例:

SCORE: 8.0

STRENGTHS:
- Clear flow from top to bottom
- All phases properly labeled
- Professional typography

ISSUES:
- Participant counts slightly small
- Minor overlap on exclusion box

VERDICT: ACCEPTABLE (for poster, threshold 7.0)
决策点:继续还是停止?
如果得分……操作
>= threshold停止——质量已满足此文档类型的要求
< threshold使用改进后的提示词继续下一次迭代

示例:

  • 对于海报(阈值 7.0):得分为 7.5 → 迭代 1 次后完成!
  • 对于期刊(阈值 8.5):得分为 7.5 → 继续优化
后续迭代(仅在需要时进行)

如果质量低于阈值,系统会:

  1. 从 Gemini 3 Pro 的审核中提取具体问题
  2. 在提示词中加入优化说明
  3. 使用 Nano Banana Pro 重新生成
  4. 再次使用 Gemini 3 Pro 审核
  5. 重复以上步骤,直到达到阈值或达到最大迭代次数
审核日志

所有迭代都会保存,并附带包含提前停止信息的 JSON 审核日志:

{
  "user_prompt": "CONSORT participant flow diagram...",
  "doc_type": "poster",
  "quality_threshold": 7.0,
  "iterations": [
    {
      "iteration": 1,
      "image_path": "figures/consort_v1.png",
      "score": 7.5,
      "needs_improvement": false,
      "critique": "SCORE: 7.5\nSTRENGTHS:..."
    }
  ],
  "final_score": 7.5,
  "early_stop": true,
  "early_stop_reason": "Quality score 7.5 meets threshold 7.0 for poster"
}

注意: 使用智能迭代时,如果较早就达到质量要求,你可能只会看到 1 次迭代,而不是完整的 2 次!

AI 生成高级用法

Python API
from scripts.generate_schematic_ai import ScientificSchematicGenerator

# Initialize generator
generator = ScientificSchematicGenerator(
    api_key="your_openrouter_key",
    verbose=True
)

# Generate with iterative refinement (max 2 iterations)
results = generator.generate_iterative(
    user_prompt="Transformer architecture diagram",
    output_path="figures/transformer.png",
    iterations=2
)

# Access results
print(f"Final score: {results['final_score']}/10")
print(f"Final image: {results['final_image']}")

# Review individual iterations
for iteration in results['iterations']:
    print(f"Iteration {iteration['iteration']}: {iteration['score']}/10")
    print(f"Critique: {iteration['critique']}")
命令行选项
# Basic usage (default threshold 7.5/10)
python scripts/generate_schematic.py "diagram description" -o output.png

# Specify document type for appropriate quality threshold
python scripts/generate_schematic.py "diagram" -o out.png --doc-type journal      # 8.5/10
python scripts/generate_schematic.py "diagram" -o out.png --doc-type conference   # 8.0/10
python scripts/generate_schematic.py "diagram" -o out.png --doc-type poster       # 7.0/10
python scripts/generate_schematic.py "diagram" -o out.png --doc-type presentation # 6.5/10

# Custom max iterations (1-2)
python scripts/generate_schematic.py "complex diagram" -o diagram.png --iterations 2

# Verbose output (see all API calls and reviews)
python scripts/generate_schematic.py "flowchart" -o flow.png -v

# Provide API key via flag
python scripts/generate_schematic.py "diagram" -o out.png --api-key "sk-or-v1-..."

# Combine options
python scripts/generate_schematic.py "neural network" -o nn.png --doc-type journal --iterations 2 -v
提示词编写技巧

1. 明确指定布局:

✓ "Flowchart with vertical flow, top to bottom"
✓ "Architecture diagram with encoder on left, decoder on right"
✓ "Circular pathway diagram with clockwise flow"

2. 提供定量细节:

✓ "Neural network with input layer (784 nodes), hidden layer (128 nodes), output (10 nodes)"
✓ "Flowchart showing n=500 screened, n=150 excluded, n=350 randomized"
✓ "Circuit with 1kΩ resistor, 10µF capacitor, 5V source"

3. 指定视觉风格:

✓ "Minimalist block diagram with clean lines"
✓ "Detailed biological pathway with protein structures"
✓ "Technical schematic with engineering notation"

4. 要求使用特定标签:

✓ "Label all arrows with activation/inhibition"
✓ "Include layer dimensions in each box"
✓ "Show time progression with timestamps"

5. 说明颜色要求:

✓ "Use colorblind-friendly colors"
✓ "Grayscale-compatible design"
✓ "Color-code by function: blue for input, green for processing, red for output"

AI 生成示例

示例 1:CONSORT 流程图
python scripts/generate_schematic.py \
  "CONSORT participant flow diagram for randomized controlled trial. \
   Start with 'Assessed for eligibility (n=500)' at top. \
   Show 'Excluded (n=150)' with reasons: age<18 (n=80), declined (n=50), other (n=20). \
   Then 'Randomized (n=350)' splits into two arms: \
   'Treatment group (n=175)' and 'Control group (n=175)'. \
   Each arm shows 'Lost to follow-up' (n=15 and n=10). \
   End with 'Analyzed' (n=160 and n=165). \
   Use blue boxes for process steps, orange for exclusion, green for final analysis." \
  -o figures/consort.png
示例 2:神经网络架构图
python scripts/generate_schematic.py \
  "Transformer encoder-decoder architecture diagram. \
   Left side: Encoder stack with input embedding, positional encoding, \
   multi-head self-attention, add & norm, feed-forward, add & norm. \
   Right side: Decoder stack with output embedding, positional encoding, \
   masked self-attention, add & norm, cross-attention (receiving from encoder), \
   add & norm, feed-forward, add & norm, linear & softmax. \
   Show cross-attention connection from encoder to decoder with dashed line. \
   Use light blue for encoder, light red for decoder. \
   Label all components clearly." \
  -o figures/transformer.png --iterations 2
示例 3:生物通路图
python scripts/generate_schematic.py \
  "MAPK signaling pathway diagram. \
   Start with EGFR receptor at cell membrane (top). \
   Arrow down to RAS (with GTP label). \
   Arrow to RAF kinase. \
   Arrow to MEK kinase. \
   Arrow to ERK kinase. \
   Final arrow to nucleus showing gene transcription. \
   Label each arrow with 'phosphorylation' or 'activation'. \
   Use rounded rectangles for proteins, different colors for each. \
   Include membrane boundary line at top." \
  -o figures/mapk_pathway.png
示例 4:系统架构图
python scripts/generate_schematic.py \
  "IoT system architecture block diagram. \
   Bottom layer: Sensors (temperature, humidity, motion) in green boxes. \
   Middle layer: Microcontroller (ESP32) in blue box. \
   Connections to WiFi module (orange box) and Display (purple box). \
   Top layer: Cloud server (gray box) connected to mobile app (light blue box). \
   Show data flow arrows between all components. \
   Label connections with protocols: I2C, UART, WiFi, HTTPS." \
  -o figures/iot_architecture.png

命令行用法

生成科学示意图的主要入口:

# Basic usage
python scripts/generate_schematic.py "diagram description" -o output.png

# Custom iterations (max 2)
python scripts/generate_schematic.py "complex diagram" -o diagram.png --iterations 2

# Verbose mode
python scripts/generate_schematic.py "diagram" -o out.png -v

注意: Nano Banana Pro AI 生成系统会在迭代优化过程中自动进行质量审核。每次迭代都会评估科学准确性、清晰度和易用性。

最佳实践摘要

设计原则
  1. 清晰胜于复杂 - 简化内容,移除不必要的元素
  2. 风格一致 - 使用模板和样式文件
  3. 色盲友好 - 使用 Okabe-Ito 调色板和冗余编码
  4. 恰当的字体排印 - 使用无衬线字体,字号至少为 7-8 pt
  5. 矢量格式 - 发布时始终使用 PDF/SVG
技术要求
  1. 分辨率 - 优先使用矢量格式,或使用 300+ DPI 的栅格图像
  2. 文件格式 - LaTeX 使用 PDF,网页使用 SVG,PNG 作为备用格式
  3. 色彩空间 - 数字内容使用 RGB,印刷使用 CMYK(如有需要请转换)
  4. 线条粗细 - 至少为 0.5 pt,通常为 1-2 pt
  5. 文字大小 - 成稿尺寸至少为 7-8 pt
集成指南
  1. 在 LaTeX 中包含图片 - 使用 \includegraphics{} 插入生成的图片
  2. 撰写详细图注 - 描述所有元素和缩写
  3. 在正文中引用 - 在叙述中解释图表
  4. 保持一致性 - 论文中的所有图表使用相同的风格
  5. 版本控制 - 在代码库中保留提示词和生成的图片

常见问题排查

AI 生成问题

问题:文字或元素重叠

  • 解决方案:AI 生成会自动处理间距
  • 解决方案:增加迭代次数:使用 --iterations 2 以获得更好的优化效果

问题:元素未正确连接

  • 解决方案:让提示词更具体地说明连接关系和布局
  • 解决方案:增加迭代次数以获得更好的优化效果
图像质量问题

问题:导出质量差

  • 解决方案:AI 生成会自动生成高质量图像
  • 解决方案:增加迭代次数以获得更好的效果:--iterations 2

问题:生成后元素发生重叠

  • 解决方案:AI 生成会自动处理间距
  • 解决方案:增加迭代次数:使用 --iterations 2 以获得更好的优化效果
  • 解决方案:让提示词更具体地说明布局和间距要求
质量检查问题

问题:重叠检测出现误报

  • 解决方案:调整阈值:detect_overlaps(image_path, threshold=0.98)
  • 解决方案:在可视化报告中手动检查标记的区域

问题:生成的图像质量低

  • 解决方案:AI 默认会生成高质量图像
  • 解决方案:增加迭代次数以获得更好的效果:--iterations 2

问题:色盲模拟显示对比度差

  • 解决方案:在代码中明确切换到 Okabe-Ito 调色板
  • 解决方案:添加冗余编码(形状、图案、线型)
  • 解决方案:增大颜色的饱和度和明度差异

问题:检测到严重重叠

  • 解决方案:检查 overlap_report.json 以查看具体位置
  • 解决方案:增大这些特定区域的间距
  • 解决方案:使用调整后的参数重新运行并再次验证

问题:生成可视化报告失败

  • 解决方案:检查 Pillow 和 matplotlib 是否已安装
  • 解决方案:确保图像文件可读取:Image.open(path).verify()
  • 解决方案:检查是否有足够的磁盘空间来生成报告
无障碍问题

问题:灰度图中无法区分颜色

  • 解决方案:运行无障碍检查器:verify_accessibility(image_path)
  • 解决方案:添加图案、形状或线型作为冗余编码
  • 解决方案:增大相邻元素之间的对比度

问题:打印时文字太小

  • 解决方案:运行分辨率验证器:validate_resolution(image_path)
  • 解决方案:按成稿尺寸设计,使用至少 7-8 pt 的字体
  • 解决方案:在分辨率报告中检查实际尺寸

问题:无障碍检查持续失败

  • 解决方案:查看 accessibility_report.json,了解具体失败项
  • 解决方案:将颜色对比度至少提高 20%
  • 解决方案:定稿前使用实际的灰度转换进行测试

资源与参考资料

详细参考资料

如需了解特定主题的全面信息,请加载以下文件:

  • references/diagram_types.md - 科学图表类型目录及示例
  • references/best_practices.md - 出版标准与无障碍指南
外部资源

Python 库

出版标准

与其他技能的集成

此技能可与以下技能协同使用:

  • 科学写作 - 图表遵循图表最佳实践
  • 科学可视化 - 共用配色方案和样式
  • LaTeX 海报 - 为海报演示生成图表
  • 研究资助 - 为提案绘制方法图表
  • 同行评审 - 评估图表的清晰度和无障碍性

快速参考清单

提交图表前,请确认:

视觉质量
  • 使用高质量图像格式(由 AI 生成的 PNG)
  • 无重叠元素(AI 自动处理)
  • 所有组件之间留有足够间距(由 AI 优化)
  • 对齐整洁、专业
  • 所有箭头均正确连接到预期目标
无障碍性
  • 使用适合色盲人士的配色方案(Okabe-Ito)
  • 在灰度模式下显示正常(已使用无障碍检查器测试)
  • 元素之间对比度足够(已验证)
  • 在适当情况下使用冗余编码(形状 + 颜色)
  • 通过所有色盲模拟检查
排版与可读性
  • 正文尺寸下的文本至少为 7-8 pt
  • 所有元素均有清晰、完整的标签
  • 字体系列和字号保持一致
  • 无文字重叠或裁切
  • 适用时标明单位
出版标准
  • 与稿件中的其他图表保持样式一致
  • 编写完整图注,并定义所有缩写
  • 在稿件正文中适当引用
  • 符合期刊特定的尺寸要求
  • 按期刊要求的格式导出(PDF/EPS/TIFF)
质量验证(必需)
  • 已运行 run_quality_checks(),且状态为通过
  • 已检查重叠检测报告(无高严重性重叠)
  • 已通过无障碍验证(灰度和色盲)
  • 已按目标 DPI 验证分辨率(印刷需达到 300+)
  • 已生成并检查视觉质量报告
  • 所有质量报告均与图表文件一同保存
文档与版本控制
  • 已保存源文件(.tex、.py),以便日后修改
  • 已将质量报告归档至 quality_reports/ 目录
  • 已记录配置参数(颜色、间距、尺寸)
  • Git 提交包含源文件、输出文件和质量报告
  • README 或注释说明如何重新生成图表
最终集成检查
  • 图表在编译后的稿件中显示正常
  • 交叉引用有效(\ref{} 指向正确的图表)
  • 图表编号与正文引用一致
  • 图注与图表出现在正确的页面位置
  • 没有与图表相关的编译警告或错误

环境设置

# Required
export OPENROUTER_API_KEY='your_api_key_here'

# Get key at: https://openrouter.ai/keys

入门指南

最简单的用法:

python scripts/generate_schematic.py "your diagram description" -o output.png

使用此技能创建清晰、无障碍且达到出版质量的图表,有效传达复杂的科学概念。借助 AI 驱动的工作流和迭代优化,确保图表符合专业标准。

评论

支持 Markdown