mcpField
S
scientific-schematics

scientific-schematics

github.com/crazymsn设计与 UI2347 次安装22 周前更新
代码仓库

关于 scientific-schematics

面向研究人员和技术作者的科学图示生成 Skill,可根据自然语言描述制作图像。Nano Banana 2 生成图像,Gemini 3.1 Pro Preview 按文档类型的质量阈值审查,并指导后续迭代。

主要功能

  1. 01根据文字描述生成图示
  2. 02Gemini 3.1 Pro Preview 质量审查
  3. 03按文档类型设定质量阈值
  4. 04迭代优化提示词
  5. 05保存版本化图像与审查日志
  6. 06提供命令行和 Python 接口

适用场景

  1. 01制作 CONSORT 参与者流程图
  2. 02绘制神经网络架构
  3. 03可视化生物通路
  4. 04为论文或演示文稿制作图示

安装

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

$npx skills add https://github.com/crazymsn/academic-skills --skill scientific-schematics

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

包含的文件

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

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

详细介绍

科学示意图和图表

概述

科学示意图和图表能将复杂概念转化为清晰的视觉呈现,适用于发表。此技能使用 Nano Banana 2 AI 生成图表,并由 Gemini 3.1 Pro Preview 审核质量。

工作原理:

  • 用自然语言描述图表
  • Nano Banana 2 自动生成适合发表的图像
  • Gemini 3.1 Pro Preview 根据文档类型对应的标准审核质量
  • 智能迭代:仅在质量未达标准时重新生成
  • 几分钟即可获得可用于发表的成品
  • 无需编写代码、使用模板或手动绘图

不同文档类型的质量标准:

文档类型标准说明
期刊论文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 2 就会为你创建。**所有图表都会存储在 figures/ 子文件夹中,并在论文/海报中引用。

快速开始:生成任意图表

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

# 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 2 遵循科学图表最佳实践创建初始图像
  2. 第 1 次审核:Gemini 3.1 Pro Preview 根据文档类型标准评估质量
  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 2 会自动生成:

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

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

  • ✓ 布局和构图
  • ✓ 标签和注释
  • ✓ 颜色和样式
  • ✓ 质量检查和完善
  • ✓ 可直接用于出版的输出

适用于所有图表类型:

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

无需编码、模板或手动绘图。


AI 生成模式(Nano Banana 2 + Gemini 3.1 Pro Preview 审核)

智能迭代完善工作流

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

智能迭代的工作方式
┌─────────────────────────────────────────────────────┐
│  1. Generate image with Nano Banana 2             │
│                    ↓                                │
│  2. Review quality with Gemini 3.1 Pro Preview                │
│                    ↓                                │
│  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.1 Pro Preview 进行质量审核

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

  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)
决策点:继续还是停止?
如果分数……操作
>= 阈值停止——对于此文档类型,质量已足够
< 阈值使用改进后的提示词继续下一轮迭代

示例:

  • 对于海报(阈值 7.0):得分 7.5 → 迭代 1 轮后完成!
  • 对于期刊论文(阈值 8.5):得分 7.5 → 继续改进
后续迭代(仅在需要时)

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

  1. 从 Gemini 3.1 Pro Preview 的审核结果中提取具体问题
  2. 在提示词中加入改进说明
  3. 使用 Nano Banana 2 重新生成
  4. 再次使用 Gemini 3.1 Pro Preview 审核
  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 2 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/best_practices.md - 发布标准和无障碍指南
外部资源

Python 库

发布标准

与其他技能的集成

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

  • Scientific Writing - 图表遵循图示最佳实践
  • Scientific Visualization - 共用配色方案和样式
  • LaTeX Posters - 为海报演示生成图表
  • Research Grants - 为提案制作方法示意图
  • Peer Review - 评估图表的清晰度和无障碍性

快速参考清单

提交图表前,请确认:

视觉质量
  • 使用高质量图像格式(由 AI 生成的 PNG)
  • 没有重叠元素(由 AI 自动处理)
  • 所有组件之间间距充足(由 AI 优化)
  • 对齐整洁、专业
  • 所有箭头均正确连接到预期目标
无障碍性
  • 使用适合色盲人士的配色方案(Okabe-Ito)
  • 灰度模式下可正常显示(已使用无障碍检查器测试)
  • 元素之间对比度充足(已验证)
  • 适当使用冗余编码(形状 + 颜色)
  • 色盲模拟通过所有检查
排版和可读性
  • 最终尺寸下文字至少为 7-8 pt
  • 所有元素均有清晰、完整的标签
  • 字体系列和字号保持一致
  • 文字没有重叠或被截断
  • 适用时标明单位
发布标准
  • 与稿件中的其他图表风格一致
  • 撰写完整图注,并解释所有缩写
  • 在稿件正文中正确引用
  • 符合期刊对尺寸的具体要求
  • 按期刊要求的格式导出(PDF/EPS/TIFF)
质量验证(必需)
  • 运行 run_quality_checks() 并达到 PASS 状态
  • 查看重叠检测报告(严重程度高的重叠为零)
  • 通过无障碍验证(灰度和色盲检查)
  • 在目标 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