scientific-schematics
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScientific Schematics and Diagrams
科学原理图与图表
Overview
概述
Scientific schematics and diagrams transform complex concepts into clear visual representations for publication. This skill uses Nano Banana Pro AI for all diagram generation.
How it works:
- Describe your diagram in natural language
- Nano Banana Pro generates publication-quality images automatically
- Automatic iterative refinement (3 iterations by default)
- Built-in quality review and improvement
- Publication-ready output in minutes
- No coding, templates, or manual drawing required
Simply describe what you want, and Nano Banana Pro creates it. All diagrams are stored in the figures/ subfolder and referenced in papers/posters.
科学原理图与图表可将复杂概念转化为清晰的可视化表达,适用于学术出版。本技能使用Nano Banana Pro AI完成所有图表生成工作。
工作原理:
- 用自然语言描述你的图表需求
- Nano Banana Pro自动生成出版级图像
- 自动迭代优化(默认3轮迭代)
- 内置质量审核与改进机制
- 数分钟内即可生成可直接用于出版的成果
- 无需编码、模板或手动绘图
只需描述你的需求,Nano Banana Pro就能完成创作。 所有图表都会存储在figures/子文件夹中,并可在论文或海报中引用。
Quick Start: Generate Any Diagram
快速入门:生成任意图表
Create any scientific diagram by simply describing it. Nano Banana Pro handles everything automatically:
bash
undefined只需用自然语言描述图表,Nano Banana Pro会自动处理所有步骤:
bash
undefinedGenerate any scientific diagram from a description
根据描述生成任意科学图表
python scripts/generate_schematic.py "CONSORT participant flow diagram with 500 screened, 150 excluded, 350 randomized" -o figures/consort.png
python scripts/generate_schematic.py "包含500名筛查对象、150名排除对象、350名随机分组对象的CONSORT参与者流程图" -o figures/consort.png
Neural network architecture
神经网络架构图
python scripts/generate_schematic.py "Transformer encoder-decoder architecture showing multi-head attention, feed-forward layers, and residual connections" -o figures/transformer.png
python scripts/generate_schematic.py "展示多头注意力、前馈层和残差连接的Transformer编码器-解码器架构图" -o figures/transformer.png
Biological pathway
生物通路图
python scripts/generate_schematic.py "MAPK signaling pathway from EGFR to gene transcription" -o figures/mapk_pathway.png
python scripts/generate_schematic.py "从EGFR到基因转录的MAPK信号通路图" -o figures/mapk_pathway.png
Custom iterations for complex diagrams
为复杂图表设置自定义迭代次数
python scripts/generate_schematic.py "Complex circuit diagram with op-amp, resistors, and capacitors" -o figures/circuit.png --iterations 5
**What happens behind the scenes:**
1. **Generation 1**: Nano Banana Pro creates initial image following scientific diagram best practices
2. **Review 1**: AI evaluates clarity, labels, accuracy, and accessibility
3. **Generation 2**: Improved prompt based on critique, regenerate
4. **Review 2**: Second evaluation with specific feedback
5. **Generation 3**: Final polished version addressing all critiques
**Output**: Three versions (v1, v2, v3) plus a detailed review log with quality scores and critiques.python scripts/generate_schematic.py "包含运算放大器、电阻和电容的复杂电路图" -o figures/circuit.png --iterations 5
**后台处理流程:**
1. **第一轮生成**:Nano Banana Pro遵循科学图表最佳实践创建初始图像
2. **第一轮审核**:AI评估图像的清晰度、标签、准确性和可访问性
3. **第二轮生成**:基于审核意见优化提示词,重新生成图像
4. **第二轮审核**:针对具体反馈进行二次评估
5. **第三轮生成**:生成解决所有问题的最终优化版本
**输出结果**:三个版本(v1、v2、v3)以及包含质量评分和审核意见的详细审核日志。Configuration
配置
Set your OpenRouter API key:
bash
export OPENROUTER_API_KEY='your_api_key_here'Get an API key at: https://openrouter.ai/keys
设置你的OpenRouter API密钥:
bash
export OPENROUTER_API_KEY='your_api_key_here'获取API密钥地址:https://openrouter.ai/keys
AI Generation Best Practices
AI生成最佳实践
Effective Prompts for Scientific Diagrams:
✓ Good prompts (specific, detailed):
- "CONSORT flowchart showing participant flow from screening (n=500) through randomization to final analysis"
- "Transformer neural network architecture with encoder stack on left, decoder stack on right, showing multi-head attention and cross-attention connections"
- "Biological signaling cascade: EGFR receptor → RAS → RAF → MEK → ERK → nucleus, with phosphorylation steps labeled"
- "Block diagram of IoT system: sensors → microcontroller → WiFi module → cloud server → mobile app"
✗ Avoid vague prompts:
- "Make a flowchart" (too generic)
- "Neural network" (which type? what components?)
- "Pathway diagram" (which pathway? what molecules?)
Key elements to include:
- Type: Flowchart, architecture diagram, pathway, circuit, etc.
- Components: Specific elements to include
- Flow/Direction: How elements connect (left-to-right, top-to-bottom)
- Labels: Key annotations or text to include
- Style: Any specific visual requirements
Scientific Quality Guidelines (automatically applied):
- Clean white/light background
- High contrast for readability
- Clear, readable labels (minimum 10pt)
- Professional typography (sans-serif fonts)
- Colorblind-friendly colors (Okabe-Ito palette)
- Proper spacing to prevent crowding
- Scale bars, legends, axes where appropriate
科学图表的有效提示词:
✓ 优质提示词(具体、详细):
- "展示从筛查(n=500)到随机分组再到最终分析的参与者流程的CONSORT流程图"
- "左侧为编码器栈、右侧为解码器栈,展示多头注意力和交叉注意力连接的Transformer神经网络架构图"
- "生物信号级联:EGFR受体 → RAS → RAF → MEK → ERK → 细胞核,标注磷酸化步骤"
- "IoT系统框图:传感器 → 微控制器 → WiFi模块 → 云服务器 → 移动应用"
✗ 应避免模糊提示词:
- "制作一个流程图"(过于笼统)
- "神经网络"(哪种类型?包含哪些组件?)
- "通路图"(哪种通路?包含哪些分子?)
提示词应包含的关键要素:
- 类型:流程图、架构图、通路图、电路图等
- 组件:需要包含的具体元素
- 流向/方向:元素的连接方式(从左到右、从上到下等)
- 标签:需要包含的关键注释或文本
- 样式:任何特定的视觉要求
自动应用的科学质量准则:
- 简洁的白色/浅色背景
- 高对比度以提升可读性
- 清晰易读的标签(最小10号字体)
- 专业排版(无衬线字体)
- 色盲友好配色(Okabe-Ito调色板)
- 合理间距避免拥挤
- 必要时添加比例尺、图例和坐标轴
Classic Code-Based Generation
传统代码生成方式
For reproducible, version-controlled diagrams with full programmatic control, use the traditional code-based approach.
如需可复现、可版本控制且支持完全程序化控制的图表,可使用传统的代码生成方式。
When to Use This Skill
何时使用本技能
This skill should be used when:
- Creating neural network architecture diagrams (Transformers, CNNs, RNNs, etc.)
- Illustrating system architectures and data flow diagrams
- Drawing methodology flowcharts for study design (CONSORT, PRISMA)
- Visualizing algorithm workflows and processing pipelines
- Creating circuit diagrams and electrical schematics
- Depicting biological pathways and molecular interactions
- Generating network topologies and hierarchical structures
- Illustrating conceptual frameworks and theoretical models
- Designing block diagrams for technical papers
本技能适用于以下场景:
- 创建神经网络架构图(Transformer、CNN、RNN等)
- 绘制系统架构和数据流图
- 为研究设计绘制方法学流程图(CONSORT、PRISMA等)
- 可视化算法工作流和处理管道
- 创建电路图和电气原理图
- 描绘生物通路和分子相互作用
- 生成网络拓扑和层次结构
- 展示概念框架和理论模型
- 为技术论文设计框图
How to Use This Skill
如何使用本技能
Simply describe your diagram in natural language. Nano Banana Pro generates it automatically:
bash
python scripts/generate_schematic.py "your diagram description" -o output.pngThat's it! The AI handles:
- ✓ Layout and composition
- ✓ Labels and annotations
- ✓ Colors and styling
- ✓ Quality review and refinement
- ✓ Publication-ready output
Works for all diagram types:
- Flowcharts (CONSORT, PRISMA, etc.)
- Neural network architectures
- Biological pathways
- Circuit diagrams
- System architectures
- Block diagrams
- Any scientific visualization
No coding, no templates, no manual drawing required.
只需用自然语言描述你的图表需求,Nano Banana Pro会自动生成:
bash
python scripts/generate_schematic.py "你的图表描述" -o output.png就是这么简单! AI会处理以下所有事项:
- ✓ 布局与构图
- ✓ 标签与注释
- ✓ 配色与样式
- ✓ 质量审核与优化
- ✓ 可直接用于出版的输出结果
支持所有图表类型:
- 流程图(CONSORT、PRISMA等)
- 神经网络架构图
- 生物通路图
- 电路图
- 系统架构图
- 框图
- 任何科学可视化图表
无需编码、无需模板、无需手动绘图。
AI Generation Mode (Nano Banana Pro)
AI生成模式(Nano Banana Pro)
Iterative Refinement Workflow
迭代优化工作流
The AI generation system uses a sophisticated three-iteration refinement process:
AI生成系统采用成熟的三轮迭代优化流程:
Iteration 1: Initial Generation
第一轮:初始生成
Prompt Construction:
Scientific diagram guidelines + User requestExample internal prompt:
Create a high-quality scientific diagram with:
- Clean white background
- High contrast for readability
- Clear labels (minimum 10pt font)
- Professional typography
- Colorblind-friendly colors
- Proper spacing
USER REQUEST: CONSORT participant flow diagram showing screening,
exclusion, randomization, and analysis phases with participant countsOutput:
diagram_v1.png提示词构建:
科学图表准则 + 用户需求内部提示词示例:
创建高质量科学图表,要求:
- 简洁的白色背景
- 高对比度以提升可读性
- 清晰的标签(最小10号字体)
- 专业排版
- 色盲友好配色
- 合理间距
用户需求:展示筛查、排除、随机分组和分析阶段及参与者数量的CONSORT参与者流程图输出结果:
diagram_v1.pngIteration 2: Review and Improve
第二轮:审核与改进
AI Quality Review:
- Evaluates scientific accuracy
- Checks label clarity and readability
- Assesses layout and composition
- Verifies accessibility (grayscale, colorblind)
- Assigns quality score (0-10)
- Provides specific improvement suggestions
Example critique:
Score: 7/10
Strengths:
- Clear flow from top to bottom
- Good use of colors
- All phases labeled
Issues:
- Participant counts (n=X) are too small to read
- "Excluded" box overlaps with arrow
- Would benefit from reasons for exclusion
Suggestions:
- Increase font size for all numbers to at least 12pt
- Add more vertical spacing between boxes
- Include exclusion criteria in a separate annotation boxImproved Prompt:
[Original guidelines + user request]
ITERATION 2: Address these improvements:
- Increase font size for participant counts to 12pt minimum
- Add vertical spacing to prevent overlaps
- Include exclusion criteria in annotation boxOutput:
diagram_v2.pngAI质量审核:
- 评估科学准确性
- 检查标签的清晰度和可读性
- 评估布局与构图
- 验证可访问性(灰度模式、色盲友好性)
- 给出质量评分(0-10分)
- 提供具体的改进建议
审核意见示例:
评分:7/10
优点:
- 从上到下的流程清晰
- 配色合理
- 所有阶段均已标注
问题:
- 参与者数量(n=X)字体过小,难以阅读
- "排除"框与箭头重叠
- 补充排除原因会更完善
建议:
- 将所有数字的字体大小增加至至少12号
- 增加框之间的垂直间距
- 在单独的注释框中列出排除标准优化后的提示词:
[原始准则 + 用户需求]
第二轮迭代:解决以下问题:
- 将参与者数量的字体大小增加至至少12号
- 增加垂直间距以避免重叠
- 在注释框中列出排除标准输出结果:
diagram_v2.pngIteration 3: Final Polish
第三轮:最终优化
Second Review:
- Verifies improvements were implemented
- Checks for any remaining issues
- Final quality assessment
Final Generation:
- Incorporates all feedback
- Produces publication-ready diagram
Output: (final version)
diagram_v3.png二次审核:
- 验证改进措施是否已落实
- 检查是否存在剩余问题
- 最终质量评估
最终生成:
- 整合所有反馈意见
- 生成可直接用于出版的图表
输出结果:(最终版本)
diagram_v3.pngReview Log
审核日志
All iterations are saved with a JSON review log:
json
{
"user_prompt": "CONSORT participant flow diagram...",
"iterations": [
{
"iteration": 1,
"image_path": "figures/consort_v1.png",
"score": 7.0,
"critique": "..."
},
{
"iteration": 2,
"image_path": "figures/consort_v2.png",
"score": 8.5,
"critique": "..."
},
{
"iteration": 3,
"image_path": "figures/consort_v3.png",
"score": 9.5,
"critique": "..."
}
],
"final_score": 9.5
}所有迭代过程会与JSON格式的审核日志一起保存:
json
{
"user_prompt": "CONSORT参与者流程图...",
"iterations": [
{
"iteration": 1,
"image_path": "figures/consort_v1.png",
"score": 7.0,
"critique": "..."
},
{
"iteration": 2,
"image_path": "figures/consort_v2.png",
"score": 8.5,
"critique": "..."
},
{
"iteration": 3,
"image_path": "figures/consort_v3.png",
"score": 9.5,
"critique": "..."
}
],
"final_score": 9.5
}Advanced AI Generation Usage
AI生成高级用法
Python API
Python API
python
from scripts.generate_schematic_ai import ScientificSchematicGeneratorpython
from scripts.generate_schematic_ai import ScientificSchematicGeneratorInitialize generator
初始化生成器
generator = ScientificSchematicGenerator(
api_key="your_openrouter_key",
verbose=True
)
generator = ScientificSchematicGenerator(
api_key="your_openrouter_key",
verbose=True
)
Generate with iterative refinement
生成带迭代优化的图表
results = generator.generate_iterative(
user_prompt="Transformer architecture diagram",
output_path="figures/transformer.png",
iterations=3
)
results = generator.generate_iterative(
user_prompt="Transformer架构图",
output_path="figures/transformer.png",
iterations=3
)
Access results
访问结果
print(f"Final score: {results['final_score']}/10")
print(f"Final image: {results['final_image']}")
print(f"最终评分: {results['final_score']}/10")
print(f"最终图像: {results['final_image']}")
Review individual iterations
查看各迭代阶段的审核结果
for iteration in results['iterations']:
print(f"Iteration {iteration['iteration']}: {iteration['score']}/10")
print(f"Critique: {iteration['critique']}")
undefinedfor iteration in results['iterations']:
print(f"第{iteration['iteration']}轮迭代: {iteration['score']}/10")
print(f"审核意见: {iteration['critique']}")
undefinedCommand-Line Options
命令行选项
bash
undefinedbash
undefinedBasic usage
基础用法
python scripts/generate_schematic.py "diagram description" -o output.png
python scripts/generate_schematic.py "图表描述" -o output.png
Custom iterations (1-10)
自定义迭代次数(1-10次)
python scripts/generate_schematic.py "complex diagram" -o diagram.png --iterations 5
python scripts/generate_schematic.py "复杂图表" -o diagram.png --iterations 5
Verbose output (see all API calls and reviews)
详细输出(查看所有API调用和审核过程)
python scripts/generate_schematic.py "flowchart" -o flow.png -v
python scripts/generate_schematic.py "流程图" -o flow.png -v
Provide API key via flag
通过参数传入API密钥
python scripts/generate_schematic.py "diagram" -o out.png --api-key "sk-or-v1-..."
undefinedpython scripts/generate_schematic.py "图表" -o out.png --api-key "sk-or-v1-..."
undefinedPrompt Engineering Tips
提示词工程技巧
1. Be Specific About Layout:
✓ "Flowchart with vertical flow, top to bottom"
✓ "Architecture diagram with encoder on left, decoder on right"
✓ "Circular pathway diagram with clockwise flow"2. Include Quantitative Details:
✓ "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. Specify Visual Style:
✓ "Minimalist block diagram with clean lines"
✓ "Detailed biological pathway with protein structures"
✓ "Technical schematic with engineering notation"4. Request Specific Labels:
✓ "Label all arrows with activation/inhibition"
✓ "Include layer dimensions in each box"
✓ "Show time progression with timestamps"5. Mention Color Requirements:
✓ "Use colorblind-friendly colors"
✓ "Grayscale-compatible design"
✓ "Color-code by function: blue for input, green for processing, red for output"1. 明确布局要求:
✓ "垂直流向、从上到下的流程图"
✓ "左侧为编码器、右侧为解码器的架构图"
✓ "顺时针流向的环形通路图"2. 包含量化细节:
✓ "输入层(784个节点)、隐藏层(128个节点)、输出层(10个节点)的神经网络"
✓ "展示n=500名筛查、n=150名排除、n=350名随机分组的流程图"
✓ "包含1kΩ电阻、10µF电容、5V电源的电路图"3. 指定视觉样式:
✓ "线条简洁的极简主义框图"
✓ "包含蛋白质结构的详细生物通路图"
✓ "带有工程符号的技术原理图"4. 要求特定标签:
✓ "为所有箭头标注激活/抑制"
✓ "在每个框中包含层维度"
✓ "用时间戳展示时间进程"5. 提及配色要求:
✓ "使用色盲友好配色"
✓ "兼容灰度模式的设计"
✓ "按功能配色:蓝色代表输入、绿色代表处理、红色代表输出"AI Generation Examples
AI生成示例
Example 1: CONSORT Flowchart
示例1:CONSORT流程图
bash
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.pngbash
python scripts/generate_schematic.py \
"随机对照试验的CONSORT参与者流程图。 \
顶部为'评估合格性(n=500)'。 \
展示'排除(n=150)'及原因:年龄<18岁(n=80)、拒绝参与(n=50)、其他(n=20)。 \
之后'随机分组(n=350)'分为两组: \
'治疗组(n=175)'和'对照组(n=175)'。 \
每组展示'失访'(n=15和n=10)。 \
最终为'完成分析'(n=160和n=165)。 \
流程步骤用蓝色框、排除用橙色框、最终分析用绿色框。" \
-o figures/consort.pngExample 2: Neural Network Architecture
示例2:神经网络架构图
bash
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 3bash
python scripts/generate_schematic.py \
"Transformer编码器-解码器架构图。 \
左侧:编码器栈包含输入嵌入、位置编码、 \
多头自注意力、加法与归一化、前馈网络、加法与归一化。 \
右侧:解码器栈包含输出嵌入、位置编码、 \
掩码自注意力、加法与归一化、交叉注意力(接收编码器输出)、 \
加法与归一化、前馈网络、加法与归一化、线性层与softmax。 \
用虚线展示编码器到解码器的交叉注意力连接。 \
编码器用浅蓝色、解码器用浅红色。 \
清晰标注所有组件。" \
-o figures/transformer.png --iterations 3Example 3: Biological Pathway
示例3:生物通路图
bash
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.pngbash
python scripts/generate_schematic.py \
"MAPK信号通路图。 \
顶部细胞膜处为EGFR受体。 \
箭头向下指向RAS(标注GTP)。 \
箭头指向RAF激酶。 \
箭头指向MEK激酶。 \
箭头指向ERK激酶。 \
最终箭头指向标注基因转录的细胞核。 \
为每个箭头标注'磷酸化'或'激活'。 \
蛋白质用圆角矩形,每个蛋白质用不同颜色。 \
顶部包含细胞膜边界线。" \
-o figures/mapk_pathway.pngExample 4: System Architecture
示例4:系统架构图
bash
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.pngbash
python scripts/generate_schematic.py \
"IoT系统架构框图。 \
底层:传感器(温度、湿度、运动)用绿色框。 \
中层:微控制器(ESP32)用蓝色框。 \
连接到WiFi模块(橙色框)和显示屏(紫色框)。 \
顶层:云服务器(灰色框)连接到移动应用(浅蓝色框)。 \
展示所有组件间的数据流箭头。 \
为连接标注协议:I2C、UART、WiFi、HTTPS。" \
-o figures/iot_architecture.pngAdditional Tools
附加工具
TikZ Compilation (compile_tikz.py)
TikZ编译工具(compile_tikz.py)
If you have existing TikZ files that need compilation:
.texbash
undefined如果你有需要编译的现有TikZ 文件:
.texbash
undefinedCompile TikZ diagram to PDF
将TikZ图编译为PDF
python scripts/compile_tikz.py diagram.tex -o diagram.pdf
python scripts/compile_tikz.py diagram.tex -o diagram.pdf
Compile and generate PNG
编译并生成PNG
python scripts/compile_tikz.py diagram.tex --png --dpi 300
python scripts/compile_tikz.py diagram.tex --png --dpi 300
Compile and preview
编译并预览
python scripts/compile_tikz.py diagram.tex --preview
For details on using `compile_tikz.py`, run:
```bash
python scripts/compile_tikz.py --helppython scripts/compile_tikz.py diagram.tex --preview
如需了解`compile_tikz.py`的详细用法,运行:
```bash
python scripts/compile_tikz.py --helpUnified Entry Point: generate_schematic.py
统一入口:generate_schematic.py
The main entry point supports both AI and code-based generation:
bash
undefined主入口同时支持AI生成和代码生成:
bash
undefinedAI generation (default)
AI生成(默认)
python scripts/generate_schematic.py "diagram description" -o output.png
python scripts/generate_schematic.py "图表描述" -o output.png
Explicit AI method
显式指定AI方法
python scripts/generate_schematic.py "diagram description" -o output.png --method ai
python scripts/generate_schematic.py "图表描述" -o output.png --method ai
Code-based generation
代码生成
python scripts/generate_schematic.py "1. Step one\n2. Step two" -o flow.tex --method code --type flowchart
python scripts/generate_schematic.py "1. 步骤一\n2. 步骤二" -o flow.tex --method code --type flowchart
Custom iterations for AI
为AI生成设置自定义迭代次数
python scripts/generate_schematic.py "complex diagram" -o diagram.png --iterations 5
python scripts/generate_schematic.py "复杂图表" -o diagram.png --iterations 5
Verbose mode
详细模式
python scripts/generate_schematic.py "diagram" -o out.png -v
**Method Selection:**
- `--method ai`: Use Nano Banana Pro with iterative refinement (default)
- `--method code`: Use traditional code-based generation
**Code-Based Types:**
- `--type flowchart`: Generate TikZ flowchart
- `--type circuit`: Generate circuit diagram
- `--type pathway`: Generate biological pathwaypython scripts/generate_schematic.py "图表" -o out.png -v
**方法选择:**
- `--method ai`:使用带迭代优化的Nano Banana Pro(默认)
- `--method code`:使用传统代码生成方式
**代码生成类型:**
- `--type flowchart`:生成TikZ流程图
- `--type circuit`:生成电路图
- `--type pathway`:生成生物通路图Helper Scripts
辅助脚本
compile_tikz.py
compile_tikz.pycompile_tikz.py
compile_tikz.pyStandalone TikZ compilation utility with quality checks:
bash
undefined带质量检查的独立TikZ编译工具:
bash
undefinedCompile TikZ to PDF with verification
编译TikZ为PDF并验证
python scripts/compile_tikz.py flowchart.tex -o flowchart.pdf --verify
python scripts/compile_tikz.py flowchart.tex -o flowchart.pdf --verify
Generate PNG with quality report
生成带质量报告的PNG
python scripts/compile_tikz.py flowchart.tex -o flowchart.pdf --png --dpi 300 --verify
python scripts/compile_tikz.py flowchart.tex -o flowchart.pdf --png --dpi 300 --verify
Preview with quality overlay
预览并显示质量叠加层
python scripts/compile_tikz.py flowchart.tex --preview --show-quality
**Note:** The Nano Banana Pro AI generation system includes automatic quality review in its iterative refinement process. Each iteration is evaluated for scientific accuracy, clarity, and accessibility.python scripts/compile_tikz.py flowchart.tex --preview --show-quality
**注意**:Nano Banana Pro AI生成系统在迭代优化过程中包含自动质量审核,每一轮迭代都会评估科学准确性、清晰度和可访问性。Best Practices Summary
最佳实践总结
Design Principles
设计原则
- Clarity over complexity - Simplify, remove unnecessary elements
- Consistent styling - Use templates and style files
- Colorblind accessibility - Use Okabe-Ito palette, redundant encoding
- Appropriate typography - Sans-serif fonts, minimum 7-8 pt
- Vector format - Always use PDF/SVG for publication
- 清晰度优先于复杂度 - 简化内容,移除不必要元素
- 样式一致性 - 使用模板和样式文件
- 色盲可访问性 - 使用Okabe-Ito调色板,添加冗余编码
- 合适的排版 - 无衬线字体,最小7-8号
- 矢量格式 - 出版时始终使用PDF/SVG
Technical Requirements
技术要求
- Resolution - Vector preferred, or 300+ DPI for raster
- File format - PDF for LaTeX, SVG for web, PNG as fallback
- Color space - RGB for digital, CMYK for print (convert if needed)
- Line weights - Minimum 0.5 pt, typical 1-2 pt
- Text size - 7-8 pt minimum at final size
- 分辨率 - 优先使用矢量格式,或300+ DPI的光栅格式
- 文件格式 - LaTeX用PDF,网页用SVG,PNG作为备选
- 色彩空间 - 数字版本用RGB,印刷版本用CMYK(必要时转换)
- 线条粗细 - 最小0.5pt,通常1-2pt
- 文字大小 - 最终尺寸下最小7-8号
Integration Guidelines
集成指南
- Include in LaTeX - Use for TikZ,
\input{}for external\includegraphics{} - Caption thoroughly - Describe all elements and abbreviations
- Reference in text - Explain diagram in narrative flow
- Maintain consistency - Same style across all figures in paper
- Version control - Keep source files (.tex, .py) in repository
- 在LaTeX中使用 - TikZ文件用,外部文件用
\input{}\includegraphics{} - 详细说明图注 - 描述所有元素和缩写
- 在正文中引用 - 在叙述中解释图表内容
- 保持一致性 - 论文中所有图表使用相同样式
- 版本控制 - 在代码库中保留源文件(.tex、.py)
Troubleshooting Common Issues
常见问题排查
TikZ Compilation Errors
TikZ编译错误
Problem:
! Package tikz Error: I do not know the key '/tikz/...- Solution: Missing library - add to preamble
\usetikzlibrary{...}
Problem: Overlapping text or elements
- Solution: Use AI generation which automatically handles spacing
- Solution: Increase iterations: for better refinement
--iterations 5 - Solution: Use in pathway generator for automatic adjustment
auto_spacing=True
Problem: Arrows not connecting properly
- Solution: Use anchor points: ,
(node.east), etc.(node.north) - Solution: Check overlap report for arrow/node intersections
问题:
! Package tikz Error: I do not know the key '/tikz/...- 解决方案:缺少库 - 在导言区添加
\usetikzlibrary{...}
问题:文字或元素重叠
- 解决方案:使用AI生成,它会自动处理间距
- 解决方案:增加迭代次数:以获得更好的优化效果
--iterations 5 - 解决方案:在通路生成器中使用自动调整间距
auto_spacing=True
问题:箭头连接不正确
- 解决方案:使用锚点:、
(node.east)等(node.north) - 解决方案:查看重叠报告中的箭头/节点交叉情况
Python Generation Issues
Python生成问题
Problem: Schemdraw elements not aligning
- Solution: Use method for precise positioning
.at() - Solution: Enable to prevent overlaps
auto_spacing
Problem: Matplotlib text rendering issues
- Solution: Set for LaTeX rendering
plt.rcParams['text.usetex'] = True - Solution: Ensure LaTeX installation is available
Problem: Export quality poor
- Solution: AI generation produces high-quality images automatically
- Solution: For TikZ, use:
python scripts/compile_tikz.py diagram.tex --png --dpi 300
Problem: Elements overlap after generation
- Solution: Run function to identify problem regions
detect_overlaps() - Solution: Use iterative refinement:
iterative_diagram_refinement(create_function) - Solution: Increase spacing between elements by 20-30%
问题:Schemdraw元素对齐错误
- 解决方案:使用方法精确定位
.at() - 解决方案:启用避免重叠
auto_spacing
问题:Matplotlib文字渲染问题
- 解决方案:设置使用LaTeX渲染
plt.rcParams['text.usetex'] = True - 解决方案:确保已安装LaTeX
问题:导出质量差
- 解决方案:AI生成默认会生成高质量图像
- 解决方案:对于TikZ文件,使用:
python scripts/compile_tikz.py diagram.tex --png --dpi 300
问题:生成后元素重叠
- 解决方案:运行函数识别问题区域
detect_overlaps() - 解决方案:使用迭代优化:
iterative_diagram_refinement(create_function) - 解决方案:增加元素间的间距20-30%
Quality Check Issues
质量检查问题
Problem: False positive overlap detection
- Solution: Adjust threshold:
detect_overlaps(image_path, threshold=0.98) - Solution: Manually review flagged regions in visual report
Problem: Generated image quality is low
- Solution: AI generation produces high-quality images by default
- Solution: Increase iterations for better results:
--iterations 5
Problem: Colorblind simulation shows poor contrast
- Solution: Switch to Okabe-Ito palette explicitly in code
- Solution: Add redundant encoding (shapes, patterns, line styles)
- Solution: Increase color saturation and lightness differences
Problem: High-severity overlaps detected
- Solution: Review overlap_report.json for exact positions
- Solution: Increase spacing in those specific regions
- Solution: Re-run with adjusted parameters and verify again
Problem: Visual report generation fails
- Solution: Check Pillow and matplotlib installations
- Solution: Ensure image file is readable:
Image.open(path).verify() - Solution: Check sufficient disk space for report generation
问题:误报重叠检测
- 解决方案:调整阈值:
detect_overlaps(image_path, threshold=0.98) - 解决方案:手动查看视觉报告中标记的区域
问题:生成的图像质量低
- 解决方案:AI生成默认会生成高质量图像
- 解决方案:增加迭代次数以获得更好结果:
--iterations 5
问题:色盲模拟显示对比度差
- 解决方案:在代码中显式切换到Okabe-Ito调色板
- 解决方案:添加冗余编码(形状、图案、线条样式)
- 解决方案:增加色彩饱和度和亮度差异
问题:检测到高严重程度的重叠
- 解决方案:查看overlap_report.json中的具体位置
- 解决方案:增加这些特定区域的间距
- 解决方案:调整参数后重新运行并验证
问题:视觉报告生成失败
- 解决方案:检查Pillow和matplotlib是否已安装
- 解决方案:确保图像文件可读:
Image.open(path).verify() - 解决方案:检查是否有足够的磁盘空间生成报告
Accessibility Problems
可访问性问题
Problem: Colors indistinguishable in grayscale
- Solution: Run accessibility checker:
verify_accessibility(image_path) - Solution: Add patterns, shapes, or line styles for redundancy
- Solution: Increase contrast between adjacent elements
Problem: Text too small when printed
- Solution: Run resolution validator:
validate_resolution(image_path) - Solution: Design at final size, use minimum 7-8 pt fonts
- Solution: Check physical dimensions in resolution report
Problem: Accessibility checks consistently fail
- Solution: Review accessibility_report.json for specific failures
- Solution: Increase color contrast by at least 20%
- Solution: Test with actual grayscale conversion before finalizing
问题:灰度模式下颜色难以区分
- 解决方案:运行可访问性检查器:
verify_accessibility(image_path) - 解决方案:添加图案、形状或线条样式作为冗余
- 解决方案:增加相邻元素的对比度
问题:打印后文字过小
- 解决方案:运行分辨率验证器:
validate_resolution(image_path) - 解决方案:按最终尺寸设计,使用最小7-8号字体
- 解决方案:查看分辨率报告中的物理尺寸
问题:可访问性检查持续失败
- 解决方案:查看accessibility_report.json中的具体失败项
- 解决方案:将色彩对比度至少提高20%
- 解决方案:在最终确定前用实际灰度转换测试
Resources and References
资源与参考
Detailed References
详细参考
Load these files for comprehensive information on specific topics:
- - Complete TikZ syntax, positioning, styles, and techniques
references/tikz_guide.md - - Catalog of scientific diagram types with examples
references/diagram_types.md - - Publication standards and accessibility guidelines
references/best_practices.md - - Guide to Schemdraw, NetworkX, and Matplotlib for diagrams
references/python_libraries.md
加载以下文件获取特定主题的全面信息:
- - 完整的TikZ语法、定位、样式和技巧
references/tikz_guide.md - - 科学图表类型目录及示例
references/diagram_types.md - - 出版标准和可访问性指南
references/best_practices.md - - Schemdraw、NetworkX和Matplotlib图表生成指南
references/python_libraries.md
External Resources
外部资源
TikZ and LaTeX
- TikZ & PGF Manual: https://pgf-tikz.github.io/pgf/pgfmanual.pdf
- TeXample.net: http://www.texample.net/tikz/ (examples gallery)
- CircuitikZ Manual: https://ctan.org/pkg/circuitikz
Python Libraries
- Schemdraw Documentation: https://schemdraw.readthedocs.io/
- NetworkX Documentation: https://networkx.org/documentation/
- Matplotlib Documentation: https://matplotlib.org/
Publication Standards
- Nature Figure Guidelines: https://www.nature.com/nature/for-authors/final-submission
- Science Figure Guidelines: https://www.science.org/content/page/instructions-preparing-initial-manuscript
- CONSORT Diagram: http://www.consort-statement.org/consort-statement/flow-diagram
TikZ与LaTeX
- TikZ & PGF手册:https://pgf-tikz.github.io/pgf/pgfmanual.pdf
- TeXample.net: http://www.texample.net/tikz/(示例图库)
- CircuitikZ手册:https://ctan.org/pkg/circuitikz
Python库
- Schemdraw文档:https://schemdraw.readthedocs.io/
- NetworkX文档:https://networkx.org/documentation/
- Matplotlib文档:https://matplotlib.org/
出版标准
Integration with Other Skills
与其他技能的集成
This skill works synergistically with:
- Scientific Writing - Diagrams follow figure best practices
- Scientific Visualization - Shares color palettes and styling
- LaTeX Posters - Reuse TikZ styles for poster diagrams
- Research Grants - Methodology diagrams for proposals
- Peer Review - Evaluate diagram clarity and accessibility
本技能可与以下技能协同使用:
- 科学写作 - 图表遵循图表最佳实践
- 科学可视化 - 共享调色板和样式
- LaTeX海报 - 复用TikZ样式制作海报图表
- 研究资助 - 为提案制作方法学图表
- 同行评审 - 评估图表的清晰度和可访问性
Quick Reference Checklist
快速参考检查清单
Before submitting diagrams, verify:
提交图表前,请验证以下内容:
Visual Quality
视觉质量
- High-quality image format (PNG from AI generation)
- No overlapping elements (AI handles automatically)
- Adequate spacing between all components (AI optimizes)
- Clean, professional alignment
- All arrows connect properly to intended targets
- 高质量图像格式(AI生成的PNG)
- 无重叠元素(AI自动处理)
- 所有组件间间距充足(AI优化)
- 整洁、专业的对齐
- 所有箭头正确连接到目标元素
Accessibility
可访问性
- Colorblind-safe palette (Okabe-Ito) used
- Works in grayscale (tested with accessibility checker)
- Sufficient contrast between elements (verified)
- Redundant encoding where appropriate (shapes + colors)
- Colorblind simulation passes all checks
- 使用了色盲安全调色板(Okabe-Ito)
- 兼容灰度模式(已用可访问性检查器测试)
- 元素间对比度充足(已验证)
- 适当添加了冗余编码(形状+颜色)
- 色盲模拟通过所有检查
Typography and Readability
排版与可读性
- Text minimum 7-8 pt at final size
- All elements labeled clearly and completely
- Consistent font family and sizing
- No text overlaps or cutoffs
- Units included where applicable
- 最终尺寸下文字最小7-8号
- 所有元素标注清晰完整
- 字体家族和大小一致
- 无文字重叠或截断
- 必要时包含单位
Publication Standards
出版标准
- Consistent styling with other figures in manuscript
- Comprehensive caption written with all abbreviations defined
- Referenced appropriately in manuscript text
- Meets journal-specific dimension requirements
- Exported in required format for journal (PDF/EPS/TIFF)
- 与手稿中其他图表样式一致
- 撰写了包含所有缩写定义的全面图注
- 在手稿正文中正确引用
- 符合期刊特定尺寸要求
- 按期刊要求导出格式(PDF/EPS/TIFF)
Quality Verification (Required)
质量验证(必需)
- Ran and achieved PASS status
run_quality_checks() - Reviewed overlap detection report (zero high-severity overlaps)
- Passed accessibility verification (grayscale and colorblind)
- Resolution validated at target DPI (300+ for print)
- Visual quality report generated and reviewed
- All quality reports saved with figure files
- 运行并获得PASS状态
run_quality_checks() - 查看重叠检测报告(无高严重程度重叠)
- 通过可访问性验证(灰度和色盲友好)
- 目标DPI分辨率已验证(印刷用300+)
- 生成并查看视觉质量报告
- 所有质量报告与图表文件一起保存
Documentation and Version Control
文档与版本控制
- Source files (.tex, .py) saved for future revision
- Quality reports archived in directory
quality_reports/ - Configuration parameters documented (colors, spacing, sizes)
- Git commit includes source, output, and quality reports
- README or comments explain how to regenerate figure
- 保存源文件(.tex、.py)以便未来修订
- 质量报告存档于目录
quality_reports/ - 配置参数已记录(颜色、间距、大小)
- Git提交包含源文件、输出文件和质量报告
- README或注释说明如何重新生成图表
Final Integration Check
最终集成检查
- Figure displays correctly in compiled manuscript
- Cross-references work (points to correct figure)
\ref{} - Figure number matches text citations
- Caption appears on correct page relative to figure
- No compilation warnings or errors related to figure
- 图表在编译后的手稿中显示正确
- 交叉引用正常工作(指向正确图表)
\ref{} - 图表编号与正文引用匹配
- 图注与图表在同一页面
- 无与图表相关的编译警告或错误
Summary: AI vs Code-Based Generation
总结:AI vs 代码生成
Quick Decision Guide
快速决策指南
Choose AI Generation (Nano Banana Pro) if:
- ✓ Speed is important (get results in minutes)
- ✓ You want automatic quality review and refinement
- ✓ The diagram is complex with many visual elements
- ✓ You prefer natural language over coding
- ✓ You need publication-ready images immediately
- ✓ You're exploring different design options
Choose Code-Based Generation if:
- ✓ You need exact reproducibility from source code
- ✓ You want version control for the diagram source
- ✓ You're generating many similar diagrams programmatically
- ✓ You need LaTeX-native TikZ integration
- ✓ You want pixel-perfect control over every element
- ✓ The diagram is generated from data/algorithms
选择AI生成(Nano Banana Pro)的场景:
- ✓ 注重速度(数分钟内获得结果)
- ✓ 希望自动进行质量审核和优化
- ✓ 图表复杂且包含大量视觉元素
- ✓ 偏好自然语言而非编码
- ✓ 需要立即获得可用于出版的图像
- ✓ 探索不同设计方案
选择代码生成的场景:
- ✓ 需要通过源代码实现精确复现
- ✓ 希望对图表源文件进行版本控制
- ✓ 程序化生成大量相似图表
- ✓ 需要与LaTeX原生TikZ集成
- ✓ 希望对每个元素进行像素级控制
- ✓ 图表由数据/算法生成
Workflow Comparison
工作流对比
| Aspect | AI Generation | Code-Based |
|---|---|---|
| Time to first result | 2-3 minutes | 15-30 minutes |
| Iterations | Automatic (3 rounds) | Manual |
| Quality review | Automatic by AI | Manual or scripted |
| Customization | Natural language | Full programmatic control |
| Reproducibility | Prompt-based | Code-based (exact) |
| Learning curve | Low (just describe) | Medium-High (learn libraries) |
| Output format | PNG/JPG | PDF/SVG/EPS/PNG |
| Version control | Prompt + images | Source code + outputs |
| Best for | Quick iteration, complex visuals | Reproducible research, data-driven |
| 方面 | AI生成 | 代码生成 |
|---|---|---|
| 首次结果耗时 | 2-3分钟 | 15-30分钟 |
| 迭代方式 | 自动(3轮) | 手动 |
| 质量审核 | AI自动完成 | 手动或脚本化 |
| 自定义程度 | 自然语言 | 完全程序化控制 |
| 可复现性 | 基于提示词 | 基于代码(精确) |
| 学习曲线 | 低(只需描述) | 中-高(学习库用法) |
| 输出格式 | PNG/JPG | PDF/SVG/EPS/PNG |
| 版本控制 | 提示词+图像 | 源代码+输出文件 |
| 最佳适用场景 | 快速迭代、复杂视觉元素 | 可复现研究、数据驱动 |
Hybrid Approach (Recommended)
混合方法(推荐)
Many users find success with a hybrid workflow:
- Prototype with AI: Generate initial designs quickly using natural language
- Review and refine: Use the AI's iterative refinement to get close to final
- Recreate in code (optional): If exact reproducibility is needed, recreate the approved design in code
- Version control: Keep both the AI prompts and code versions
许多用户通过混合工作流获得成功:
- AI原型设计:用自然语言快速生成初始设计
- 审核与优化:利用AI的迭代优化功能接近最终版本
- 代码重构(可选):如果需要精确复现,将获批设计用代码重构
- 版本控制:同时保存AI提示词和代码版本
Environment Setup
环境设置
For AI Generation:
bash
undefinedAI生成环境:
bash
undefinedRequired
必需
export OPENROUTER_API_KEY='your_api_key_here'
export OPENROUTER_API_KEY='your_api_key_here'
Get key at: https://openrouter.ai/keys
获取密钥地址: https://openrouter.ai/keys
**For Code-Based Generation:**
```bash
**代码生成环境:**
```bashInstall Graphviz
安装Graphviz
brew install graphviz # macOS
sudo apt-get install graphviz # Linux
brew install graphviz # macOS
sudo apt-get install graphviz # Linux
Install Python packages
安装Python包
pip install graphviz schemdraw networkx matplotlib
undefinedpip install graphviz schemdraw networkx matplotlib
undefinedGetting Started
快速开始
Simplest possible usage (AI):
bash
python scripts/generate_schematic.py "your diagram description" -o output.pngSimplest possible usage (Code):
bash
python scripts/generate_schematic.py "1. Step one\n2. Step two" -o flow.tex --method codeUse this skill to create clear, accessible, publication-quality diagrams that effectively communicate complex scientific concepts. The AI-powered workflow with iterative refinement ensures diagrams meet professional standards, while the code-based approach provides exact reproducibility for research publications.
最简单的AI用法:
bash
python scripts/generate_schematic.py "你的图表描述" -o output.png最简单的代码用法:
bash
python scripts/generate_schematic.py "1. 步骤一\n2. 步骤二" -o flow.tex --method code使用本技能创建清晰、可访问的出版级图表,有效传达复杂科学概念。带迭代优化的AI驱动工作流确保图表符合专业标准,而代码生成方式则为研究出版提供精确的可复现性。