| name | drawio-paper |
| description | Generate publication-quality academic paper diagrams (.drawio) and statistical plots (.png via Python/matplotlib) using a PaperBanana-inspired multi-agent pipeline. Reads methodology sections, figure captions, and raw data to produce structured, aesthetically refined visualizations with reference-driven design. |
| allowed-tools | Bash, Write, Read, Glob |
Academic Paper Visualization Skill (Diagrams + Plots)
Generate publication-quality academic paper visualizations using a structured multi-agent pipeline inspired by PaperBanana. This skill supports two output modes:
- Diagram mode: Transforms methodology sections and figure captions into polished
.drawio diagrams through retrieval, planning, styling, visualization (XML generation), and critique stages.
- Plot mode: Transforms raw data (tabular/JSON) and visual intent into publication-ready statistical plots via Python/matplotlib code generation, following the same retrieval, planning, styling, visualization (code generation + execution), and critique pipeline.
Setup (run once before first use)
Before generating diagrams or plots, ensure the PaperBananaBench reference dataset is available locally. Check if {skill_dir}/PaperBananaBench/diagram/ref.json and {skill_dir}/PaperBananaBench/plot/ref.json both exist. If either is missing, run the following setup steps:
curl -L -o "{skill_dir}/PaperBananaBench.zip" https://huggingface.co/datasets/dwzhu/PaperBananaBench/resolve/main/PaperBananaBench.zip
python "{skill_dir}/scripts/extract_bench.py"
Python environment for plots
Plots are generated using Python + matplotlib. Ensure the following packages are available:
pip install matplotlib numpy pillow
Important notes:
{skill_dir} refers to the directory containing this SKILL.md file (.claude/skills/drawio-paper/)
- Only requires
curl and Python (stdlib zipfile), no git or git-lfs needed
- Python extraction is used instead of
unzip to reliably handle long paths on Windows
- If the download fails due to network issues, retry or ask the user to manually download from https://huggingface.co/datasets/dwzhu/PaperBananaBench/resolve/main/PaperBananaBench.zip and place it at
{skill_dir}/PaperBananaBench.zip, then run the Python extraction step
- After setup,
{skill_dir}/PaperBananaBench/diagram/ and {skill_dir}/PaperBananaBench/plot/ should each contain ref.json, test.json, and an images/ folder with reference images
When to use this skill
Diagram mode
Use when the user wants to create academic paper diagrams, such as:
- Framework/architecture overview diagrams
- Pipeline/workflow diagrams
- Method illustration diagrams
- Module detail diagrams
- System design diagrams for research papers
Trigger keywords: "paper diagram", "academic diagram", "method diagram", "framework diagram", "pipeline diagram", "research figure", "paper figure", "drawio paper", "academic illustration"
Plot mode
Use when the user wants to create publication-quality statistical plots, such as:
- Bar charts, grouped bar charts, stacked bar charts
- Line charts with confidence intervals
- Scatter plots with shape/color coding
- Heatmaps and confusion matrices
- Radar/spider charts
- Pie/donut charts
- Box plots, violin plots
- Any statistical visualization for academic papers
Trigger keywords: "paper plot", "academic plot", "research plot", "statistical plot", "bar chart", "line chart", "scatter plot", "heatmap", "paper chart", "matplotlib plot", "publication plot", "results plot", "comparison plot"
Mode detection
- If the user provides methodology text + figure caption โ Diagram mode
- If the user provides raw data (table/JSON/CSV) + visual intent โ Plot mode
- If ambiguous, ask the user which mode they want
Pipeline overview
Follow this 5-stage pipeline to generate each visualization (diagram or plot). Stages 1-3 and 5 share the same structure for both modes; Stage 4 differs based on the output type.
Stage 1: Reference Retrieval
Before generating, always look at reference images from the benchmark dataset to understand the visual style expected.
For Diagram mode:
- Read the reference metadata from
{skill_dir}/PaperBananaBench/diagram/ref.json and {skill_dir}/PaperBananaBench/diagram/test.json
- Based on the user's topic (domain) and visual intent (diagram type), select 3-5 relevant reference images to study
- Use the Read tool to view the selected reference images from
{skill_dir}/PaperBananaBench/diagram/images/
- Note the visual patterns: layout structure, color schemes, grouping strategies, icon usage, arrow styles
For Plot mode:
- Read the reference metadata from
{skill_dir}/PaperBananaBench/plot/ref.json and {skill_dir}/PaperBananaBench/plot/test.json
- Based on the user's data type and desired plot type, select 3-5 relevant reference plot images to study
- Use the Read tool to view the selected reference images from
{skill_dir}/PaperBananaBench/plot/images/
- Note the visual patterns: color palette, axis styling, legend placement, annotation style, chart type conventions
Selection logic (from PaperBanana Retriever Agent):
- Match Research Topic: Find references in the same domain (e.g., Agent/Reasoning, Vision/Perception, Generative/Learning, Science/Applications)
- Match Visual Intent: Find references with similar visualization types (e.g., Framework diagram, Bar chart, Line chart, Heatmap)
- Priority: Same Topic + Same Visual Intent > Same Visual Intent > Same Topic
Stage 2: Planning
Based on the user's input and the reference images studied, create a detailed textual description.
For Diagram mode (input: methodology section + figure caption):
-
Create a detailed textual description of the diagram to generate, including:
- All components and their relationships
- Data flow direction (typically left-to-right or top-to-bottom)
- Grouping/containment hierarchy
- Labels for every element
- Mathematical notation where appropriate
-
The description should be as detailed as possible:
- Clearly describe each element and their connections
- Include background style, colors, line thickness, icon styles
- Specify layout structure (horizontal pipeline, vertical stack, grid, etc.)
For Plot mode (input: raw data + visual intent):
-
Create a detailed textual description of the plot to generate, including:
- Precise mapping of variables to visual channels (x-axis, y-axis, hue/color, size, shape)
- Explicitly enumerate every raw data point's coordinate to ensure accuracy
- Chart type selection and justification
- All axis labels, tick values, and units
- Legend content and placement
-
The description should specify exact aesthetic parameters:
- Specific HEX color codes for each data series
- Font sizes for all labels (title, axes, ticks, legend, annotations)
- Line widths, marker dimensions, bar widths
- Grid style (dashed/dotted, color, alpha)
- Legend placement (inside plot, top horizontal, etc.)
Stage 3: Style Refinement
For Diagram mode:
Apply the NeurIPS 2025 academic diagram style guide (stored at {skill_dir}/neurips2025_diagram_style_guide.md) to refine the planned description:
Key style principles:
- Color: "Soft Tech & Scientific Pastels" - use light pastel backgrounds (#E6F3FF, #F3E5F5, #E0F2F1, #F5F5DC) for zones, medium saturation for active modules
- Shapes: "Softened Geometry" - rounded rectangles for processes, 3D cuboids for tensors, cylinders for databases
- Lines: Orthogonal edges for architectures, curved for data flow; solid for forward pass, dashed for auxiliary/gradient flow
- Typography: Sans-serif (Arial) for labels, serif (Times New Roman) for math variables
- Icons: Use semantic icons (snowflake=frozen, fire=trainable, gear=processing)
- Background: Pure white or very light pastels; avoid saturated backgrounds
- No figure caption text inside the diagram itself
Domain-specific styles:
- Agent/LLM papers: Illustrative, friendly, chat bubbles, robot avatars
- Computer Vision/3D: Spatial, dense, geometric, RGB color coding, heatmaps
- Theoretical/Optimization: Minimalist, abstract, graph nodes, mostly grayscale
For Plot mode:
Apply the NeurIPS 2025 statistical plot aesthetics guide (stored at {skill_dir}/neurips2025_plot_style_guide.md) to refine the planned description. Focus on specifying visual attributes without altering data content.
Key style principles:
- Color palettes: Soft pastels for categorical data; Viridis/Magma for sequential; avoid Jet/Rainbow
- Axes & grids: Fine dashed or dotted grid lines in light gray, behind data; either "boxed" (4 spines) or "open" (no top/right)
- Typography: Sans-serif fonts (Arial, Helvetica, DejaVu Sans); rotate x-labels 45ยฐ only when necessary
- Legends: Float inside plot area or place as horizontal row above plot
- Annotations: Prefer direct labeling over forcing legend references
- Background: White or very light gray (Seaborn-style)
- Accessibility: Combine color with shape/pattern (hatches, markers) for colorblind support
- No figure caption inside the plot itself
Chart-type-specific guidelines:
- Bar charts: Black outlines or borderless fills; tight grouping; error bars with black flat caps
- Line charts: Always include geometric markers at data points; dashed lines for baselines; shaded confidence bands
- Scatter plots: Different marker shapes for categories; solid opaque fills
- Heatmaps: Square cells; annotate exact values inside cells; use perceptually uniform colormaps
- Pie/Donut: Thick donut preferred; white borders between slices; explode key slices
- Radar charts: Translucent polygon fills (alpha ~0.2); solid outer perimeter
Stage 4: Visualization Generation
Choose the appropriate sub-stage based on mode:
Stage 4A: Draw.io XML Generation (Diagram mode)
Transform the styled description into draw.io XML. Follow ALL rules from the base drawio skill:
Basic XML structure
<mxGraphModel>
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
</root>
</mxGraphModel>
Academic diagram design patterns
Pattern 1: Horizontal Pipeline (most common)
- Left-to-right flow with major stages as titled swimlane containers
- Internal components as rounded rectangles within each stage
- Arrows connecting stages with orthogonal edges
Pattern 2: Vertical Architecture Stack
- Top-to-bottom layer stack (input at top, output at bottom)
- Each layer as a rounded rectangle with fill color indicating type
- Skip connections shown as curved dashed lines
Pattern 3: Multi-module Detail
- Central overview with breakout detail boxes connected by lines
- "Macro-Micro" pattern: overview container + zoomed-in module details
Color palette for academic diagrams
| Purpose | Color | Hex |
|---|
| Background zone - blue | Pale Ice Blue | #E6F3FF |
| Background zone - green | Pale Mint | #E0F2F1 |
| Background zone - purple | Pale Lavender | #F3E5F5 |
| Background zone - warm | Cream/Beige | #FFF8E1 |
| Active module - blue | Soft Blue | #DAE8FC |
| Active module - green | Soft Green | #D5E8D4 |
| Active module - orange | Soft Orange | #FFE6CC |
| Active module - pink | Soft Pink | #F8CECC |
| Frozen/static element | Light Grey | #F5F5F5 |
| Highlight/output | Gold accent | #FFF2CC |
| Trainable element | Warm tone | #FFE0B2 |
| Frozen element | Cool grey | #E0E0E0 |
| Border - blue | Medium Blue | #6C8EBF |
| Border - green | Medium Green | #82B366 |
| Border - orange | Medium Orange | #D6B656 |
| Border - red | Medium Red | #B85450 |
Layout rules
- Generous spacing: At least 200px horizontal gap, 120px vertical gap between major groups
- Grid alignment: Align all nodes to multiples of 10
- Container padding: At least 20px padding inside containers; startSize=30 for swimlane headers
- Font sizes: 14-16px for major labels, 11-12px for detail labels, 10px for annotations
- Edge routing: Use orthogonalEdgeStyle with rounded=1 for clean bends
- Leave room for arrowheads: At least 20px straight segment before targets
Container usage for grouping
Use draw.io containers for logical grouping (stages, modules):
<mxCell id="stage1" value="Stage 1: Encoding" style="swimlane;startSize=30;fillColor=#E6F3FF;strokeColor=#6C8EBF;rounded=1;arcSize=8;fontStyle=1;fontSize=14;fontFamily=Arial;" vertex="1" parent="1">
<mxGeometry x="40" y="80" width="300" height="400" as="geometry"/>
</mxCell>
<mxCell id="enc1" value="Encoder" style="rounded=1;whiteSpace=wrap;fillColor=#DAE8FC;strokeColor=#6C8EBF;fontSize=12;fontFamily=Arial;" vertex="1" parent="stage1">
<mxGeometry x="20" y="50" width="120" height="50" as="geometry"/>
</mxCell>
Math notation in labels
Use HTML formatting for mathematical symbols:
<mxCell id="loss" value="<i>L</i> = &sum; <i>L</i><sub>i</sub>" style="text;html=1;align=center;fontFamily=Times New Roman;fontSize=12;" vertex="1" parent="1">
<mxGeometry x="200" y="500" width="100" height="30" as="geometry"/>
</mxCell>
Semantic icons as text labels
Use Unicode/emoji characters in value attributes for semantic icons. Place them as standalone text cells or inline with labels.
<mxCell id="icon_example" value="❄" style="text;fontSize=16;align=center;" vertex="1" parent="1">
<mxGeometry x="150" y="90" width="24" height="24" as="geometry"/>
</mxCell>
Complete emoji reference for academic diagrams:
Model State
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Snowflake | โ | ❄ | Frozen / Non-trainable | Frozen encoder, fixed weights |
| Fire | ๐ฅ | 🔥 | Trainable / Active learning | Fine-tuning layers, trainable heads |
| Lightning | โก | ⚡ | Fast / Accelerated | Efficient inference, speedup |
| Lock | ๐ | 🔒 | Locked / Protected | Frozen parameters, access control |
| Unlock | ๐ | 🔓 | Unlocked / Released | Unfrozen for training |
| Stop sign | ๐ | 🛑 | Stopped / Blocked | Non-trainable, gradient stop |
Agents & Roles
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Robot | ๐ค | 🤖 | AI Agent / Model | LLM agent, autonomous module |
| Person | ๐ค | 👤 | User / Human | Human input, user query |
| People | ๐ฅ | 👥 | Multi-user / Crowd | Collaborative systems, multi-user |
| Brain | ๐ง | 🧠 | Reasoning / Intelligence | LLM core, reasoning module |
| Thinking | ๐ค | 🧐 | Evaluation / Critique | Critic agent, reviewer |
| Detective | ๐ต | 🕵 | Investigation / Analysis | Anomaly detection, inspection |
| Teacher | ๐จโ๐ซ | 👨‍🏫 | Teaching / Supervision | Teacher model, supervisor |
| Student | ๐จโ๐ | 👨‍🎓 | Learning / Student | Student model, distillation target |
Data & Content
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Document | ๐ | 📄 | Text / Document | Input text, paper, prompt |
| Clipboard | ๐ | 📋 | Plan / List | Structured plan, task list |
| Folder | ๐ | 📁 | Dataset / Collection | Data directory, file collection |
| File cabinet | ๐ | 🗃 | Storage / Archive | Knowledge base, data store |
| Database | ๐ | 🗄 | Database / Repository | Vector DB, model repository |
| Image | ๐ผ | 🖼 | Image / Visual data | Image input, visual features |
| Speech | ๐ฌ | 💬 | Chat / Dialogue | Prompt, conversation, chat bubble |
| Label | ๐ท | 🏷 | Tag / Annotation | Class label, metadata tag |
| Book | ๐ | 📚 | Knowledge / Corpus | Training corpus, reference library |
| Newspaper | ๐ฐ | 📰 | Article / Report | Paper, news, generated report |
Operations & Processing
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Gear | โ | ⚙ | Processing / Computation | Model inference, computation |
| Magnifier | ๐ | 🔍 | Search / Retrieval | Retrieval, attention, inspection |
| Wrench | ๐ง | 🔧 | Configuration / Tuning | Hyperparameter tuning, adjustment |
| Scissors | โ | ✂ | Pruning / Cutting | Model pruning, token trimming |
| Filter | ๐ฝ | 🔽 | Filtering / Selection | Feature selection, data filtering |
| Shuffle | ๐ | 🔀 | Random / Shuffle | Data augmentation, random sampling |
| Cycle | ๐ | 🔄 | Loop / Iteration | Iterative refinement, feedback loop |
| Link | ๐ | 🔗 | Connection / Linking | Cross-attention, entity linking |
| Merge | ๐ | 🔀 | Merge / Combine | Feature fusion, model merging |
Evaluation & Results
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Checkmark | โ
| ✅ | Pass / Correct | Correct prediction, quality pass |
| Cross | โ | ❌ | Fail / Incorrect | Wrong prediction, rejected |
| Trophy | ๐ | 🏆 | Best / Winner | Best model, SOTA result |
| Chart up | ๐ | 📈 | Improvement / Growth | Performance gain, metric increase |
| Chart down | ๐ | 📉 | Decline / Degradation | Performance drop, quality loss |
| Target | ๐ฏ | 🎯 | Goal / Objective | Target task, loss objective |
| Star | โญ | ⭐ | Highlight / Key result | Key contribution, important |
| Warning | โ | ⚠ | Caution / Issue | Potential problem, limitation |
Domain-Specific
| Icon | Emoji | HTML Entity | Meaning | Usage |
|---|
| Eye | ๐ | 👁 | Vision / Observation | Visual encoder, image perception |
| Ear | ๐ | 👂 | Audio / Listening | Speech recognition, audio input |
| Pen | โ | ✍ | Writing / Generation | Text generation, authoring |
| Globe | ๐ | 🌐 | Web / Global | Internet retrieval, world knowledge |
| DNA | ๐งฌ | 🧬 | Biology / Sequence | Protein, genomics, molecular |
| Atom | โ | ⚛ | Physics / Science | Scientific computing, simulation |
| Microscope | ๐ฌ | 🔬 | Research / Analysis | Detailed analysis, micro-level |
| Telescope | ๐ญ | 🔭 | Far-sighted / Overview | Macro-level, global view |
| Pill | ๐ | 💊 | Medical / Drug | Drug discovery, medical AI |
| Tree | ๐ณ | 🌳 | Tree structure / Hierarchy | Decision tree, parse tree |
| Network | ๐ธ | 🕸 | Graph / Network | Neural network, knowledge graph |
| Dice | ๐ฒ | 🎲 | Random / Stochastic | Sampling, probability, noise |
| Thermometer | ๐ก | 🌡 | Temperature | Softmax temperature, scaling |
| Hourglass | โณ | ⏳ | Time / Temporal | Time series, sequence, latency |
| Layer | ๐ | 📊 | Layers / Stack | Model layers, feature maps |
| Key | ๐ | 🔑 | Key / Authentication | Attention key, API key, decryption |
| Light bulb | ๐ก | 💡 | Idea / Insight | Innovation, key finding |
| Rocket | ๐ | 🚀 | Launch / Deploy | Model deployment, fast execution |
| Shield | ๐ก | 🛡 | Defense / Protection | Adversarial defense, safety |
| Sword | โ | ⚔ | Attack / Adversarial | Adversarial attack, red-teaming |
Mathematical Operators (use with fontFamily=Times New Roman)
| Symbol | Name | HTML Entity | Usage |
|---|
| โ | Circled plus | ⊕ | Element-wise addition, concatenation |
| โ | Circled times | ⊗ | Element-wise multiplication, outer product |
| โ | Circled dot | ⊙ | Hadamard product, dot product |
| โ | Summation | ∑ | Sum, aggregation |
| โ | Product | ∏ | Product operation |
| โ | Right arrow | → | Mapping, transformation |
| โ | Left-right arrow | ↔ | Bidirectional, mutual |
| ฯ | Sigma | σ | Sigmoid, activation |
| โ | Nabla | ∇ | Gradient |
| โ | Infinity | ∞ | Unbounded, continuous |
| โ | Element of | ∈ | Membership, belongs to |
| โ | Approximately | ≈ | Approximation |
| โฅ | Parallel | ∥ | Norm, parallel |
Dashed lines for auxiliary flow
<mxCell id="grad_flow" value="Gradient" style="edgeStyle=orthogonalEdgeStyle;dashed=1;strokeColor=#999999;fontColor=#999999;fontSize=10;" edge="1" source="loss_node" target="encoder" parent="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
Mathematical operators on edges
<mxCell id="add_op" value="⊕" style="ellipse;whiteSpace=wrap;fillColor=#FFFFFF;strokeColor=#666666;fontSize=14;fontFamily=Times New Roman;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="295" y="195" width="30" height="30" as="geometry"/>
</mxCell>
Stage 4B: Python/Matplotlib Code Generation (Plot mode)
Transform the styled description into a complete, self-contained Python script using matplotlib. The script must generate and save a publication-quality plot.
Code generation rules
-
Self-contained script: The generated Python code must be a single, complete script that can run independently. All data must be embedded directly in the code (no external file reads).
-
Required imports: Always include these at the top:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
-
Reset defaults: Always call plt.rcdefaults() before setting custom styles to avoid inheriting stale state.
-
Output format: Save the plot as PNG at 300 DPI with tight bounding box:
plt.savefig('output_filename.png', format='png', dpi=300, bbox_inches='tight', facecolor='white')
plt.close('all')
- No interactive elements: Never use
plt.show(). Always use plt.savefig() only.
Matplotlib style template
Apply these NeurIPS 2025 style settings programmatically:
plt.rcParams.update({
'font.family': 'sans-serif',
'font.sans-serif': ['Arial', 'Helvetica', 'DejaVu Sans'],
'font.size': 12,
'axes.titlesize': 14,
'axes.labelsize': 13,
'xtick.labelsize': 11,
'ytick.labelsize': 11,
'legend.fontsize': 11,
})
plt.rcParams.update({
'axes.grid': True,
'grid.alpha': 0.3,
'grid.linestyle': '--',
'grid.color': '#cccccc',
'axes.spines.top': True,
'axes.spines.right': True,
})
plt.rcParams.update({
'figure.facecolor': 'white',
'axes.facecolor': 'white',
'savefig.facecolor': 'white',
'figure.figsize': (8, 6),
})
Recommended color palettes
Categorical (soft pastels for academic look):
COLORS_PASTEL = ['#7EB6D9', '#F4A582', '#92C5A9', '#D4A5D0', '#F7DC6F', '#B0B0B0', '#E8927C', '#A8D8EA']
COLORS_EARTH = ['#4E79A7', '#F28E2B', '#E15759', '#76B7B2', '#59A14F', '#EDC948', '#B07AA1', '#FF9DA7']
COLORS_CONTRAST = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f']
Sequential/Heatmap: Use 'viridis', 'magma', 'plasma'. Never use 'jet' or 'rainbow'.
Diverging: Use 'coolwarm' or 'RdBu_r' for positive/negative splits.
Chart-type code patterns
Grouped bar chart:
x = np.arange(len(categories))
width = 0.25
fig, ax = plt.subplots(figsize=(10, 6))
for i, (label, values) in enumerate(data_series.items()):
bars = ax.bar(x + i * width, values, width, label=label,
color=COLORS_PASTEL[i], edgecolor='black', linewidth=0.8)
ax.set_xticks(x + width * (len(data_series) - 1) / 2)
ax.set_xticklabels(categories)
ax.legend(loc='upper left', framealpha=0.9)
Line chart with markers and confidence bands:
fig, ax = plt.subplots(figsize=(10, 6))
for i, (label, y_vals) in enumerate(data_series.items()):
ax.plot(x_vals, y_vals, marker='o', markersize=6, linewidth=2,
color=COLORS_EARTH[i], label=label)
ax.legend(loc='best', framealpha=0.9)
Heatmap with annotations:
fig, ax = plt.subplots(figsize=(8, 8))
im = ax.imshow(data_matrix, cmap='viridis', aspect='equal')
for i in range(data_matrix.shape[0]):
for j in range(data_matrix.shape[1]):
text_color = 'white' if data_matrix[i, j] > threshold else 'black'
ax.text(j, i, f'{data_matrix[i, j]:.2f}', ha='center', va='center',
color=text_color, fontsize=10)
plt.colorbar(im, ax=ax, shrink=0.8)
Radar/Spider chart:
angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False).tolist()
angles += angles[:1]
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
for i, (label, values) in enumerate(data_series.items()):
vals = values + values[:1]
ax.plot(angles, vals, linewidth=2, color=COLORS_EARTH[i], label=label)
ax.fill(angles, vals, alpha=0.15, color=COLORS_EARTH[i])
ax.set_xticks(angles[:-1])
ax.set_xticklabels(categories)
ax.legend(loc='upper right', bbox_to_anchor=(1.3, 1.1))
Code execution workflow
- Write the generated Python script to a
.py file using the Write tool
- Execute the script using
python <script.py> via Bash
- Check that the output
.png file was created successfully
- If execution fails, read the error, fix the code, and re-execute (up to 3 attempts)
- Open the result image
Common pitfalls to avoid
- Never use
plt.show() โ it blocks in headless mode
- Always set
matplotlib.use('Agg') before importing pyplot
- Always embed all data directly in the script; do not read external files unless the user explicitly provides a file path
- Avoid default matplotlib styling โ always customize colors, fonts, and grid to avoid the "Veto Rule" of looking like unmodified default output
- Do not include figure titles/captions inside the plot (e.g., no
fig.suptitle("Figure 3: ...")) โ captions belong in the paper, not the image
- Handle tight layout โ use
plt.tight_layout() before savefig to prevent label clipping
- Use
bbox_inches='tight' in savefig to avoid whitespace
- For bar charts with many categories, rotate x-labels 45ยฐ with
ha='right'
Stage 5: Critique and Refinement
After generating the initial output (XML for diagrams, or executing the Python script for plots), perform a self-critique:
For Diagram mode:
- Content fidelity: Does the diagram accurately reflect the methodology? Are all key components present?
- Text QA: Check for typos, unclear labels, nonsensical text
- Layout clarity: Is the flow clear? Is there visual clutter?
- Style compliance: Does it follow the academic style guide?
- Caption exclusion: Ensure no figure caption text appears inside the diagram
- Legend management: Remove redundant color legends if present
If issues are found, revise the XML and regenerate.
For Plot mode (4 evaluation dimensions from PaperBanana Critic Agent):
- Faithfulness: Does the plot correctly represent all data values? Are axis labels, legend entries, and annotations accurate? No fabricated data points or wrong chart types?
- Conciseness: No redundant labeling (e.g., both bar height AND text labels on many bars)? No unnecessary subplots? No text overload?
- Readability: Are axes labeled with units? Is text legible (no overlapping, sufficient contrast)? Are data series distinguishable? Legend present when needed? No data elements hidden behind legend?
- Aesthetics: Professional color scheme (not default matplotlib)? Consistent styling? No pixelation? No black background? No excessive 3D effects?
If issues are found, revise the Python code and re-execute.
Output workflow
Diagram mode
- Generate draw.io XML following the full pipeline above
- Write the XML to a
.drawio file using the Write tool
- If the user requested an export format (png, svg, pdf), export using the draw.io CLI with
--embed-diagram, then delete the source .drawio file
- Open the result
Plot mode
- Generate Python script following the full pipeline above
- Write the script to a
.py file using the Write tool
- Execute the script via Bash:
python <script.py>
- Verify the output
.png file exists
- Open the result image
- Optionally, keep the
.py file for the user to modify later (do not delete by default)
Choosing the output format
Diagram format
/drawio-paper create a framework diagram -> framework.drawio
/drawio-paper png pipeline for my method -> method-pipeline.drawio.png
/drawio-paper svg: architecture overview -> architecture-overview.drawio.svg
If no format is mentioned, write the .drawio file and open it.
Plot format
/drawio-paper plot a bar chart of model accuracy -> model-accuracy.png + model-accuracy.py
/drawio-paper plot pdf: training curve comparison -> training-curve.pdf + training-curve.py
/drawio-paper plot svg: ablation results -> ablation-results.svg + ablation-results.py
Default output is .png at 300 DPI. For PDF/SVG, change the format parameter in plt.savefig().
Supported export formats
| Format | Embed XML | Notes |
|---|
png | Yes (-e) | Viewable everywhere, editable in draw.io |
svg | Yes (-e) | Scalable, editable in draw.io |
pdf | Yes (-e) | Printable, editable in draw.io |
draw.io CLI
Try drawio first, then fall back to platform-specific path:
- macOS:
/Applications/draw.io.app/Contents/MacOS/draw.io
- Linux:
drawio
- Windows:
"C:\Program Files\draw.io\draw.io.exe"
Export command
drawio -x -f <format> -e -b 10 -o <output> <input.drawio>
Key flags:
-x / --export: export mode
-f / --format: output format (png, svg, pdf)
-e / --embed-diagram: embed diagram XML in output
-o / --output: output file path
-b / --border: border width (default: 0)
-s / --scale: scale diagram size
Opening the result
- macOS:
open <file>
- Linux:
xdg-open <file>
- Windows:
start <file>
File naming
- Use descriptive filenames based on content
- Lowercase with hyphens for multi-word names
- Diagrams: For export: double extensions (
name.drawio.png, name.drawio.svg). After successful export, delete the intermediate .drawio file
- Plots: Output
name.png (or .pdf/.svg) alongside name.py (the source script). Keep both files
CRITICAL: XML well-formedness
- NEVER use double hyphens (
--) inside XML comments. Use single hyphens or rephrase.
- Escape special characters in attribute values:
&, <, >, "
- Always use unique
id values for each mxCell
- Always set
html=1 in style when using HTML formatting in value
Common styles reference
| Property | Values | Use for |
|---|
rounded=1 | 0 or 1 | Rounded corners |
whiteSpace=wrap | wrap | Text wrapping |
fillColor=#dae8fc | Hex color | Background color |
strokeColor=#6c8ebf | Hex color | Border color |
fontColor=#333333 | Hex color | Text color |
shape=cylinder3 | shape name | Database cylinders |
ellipse | style keyword | Circles/ovals |
rhombus | style keyword | Diamonds |
edgeStyle=orthogonalEdgeStyle | style keyword | Right-angle connectors |
dashed=1 | 0 or 1 | Dashed lines |
swimlane | style keyword | Titled containers |
group | style keyword | Invisible containers |
container=1 | 0 or 1 | Enable container behavior |
pointerEvents=0 | 0 or 1 | Prevent container from capturing connections |
Edge routing
- Use
edgeStyle=orthogonalEdgeStyle for right-angle connectors
- Space nodes generously (200px horizontal, 120px vertical gaps)
- Use
exitX/exitY and entryX/entryY (0-1) to control connection points
- Add explicit waypoints when edges would overlap
- Use
rounded=1 on edges for cleaner bends
- Use
jettySize=auto for better port spacing
Containers and groups
Set parent="containerId" on child cells. Children use relative coordinates.
| Type | Style | When to use |
|---|
| Group (invisible) | group; | No visual border needed |
| Swimlane (titled) | swimlane;startSize=30; | Needs visible title bar |
| Custom container | Add container=1;pointerEvents=0; | Any shape as container |
Always add pointerEvents=0; to container styles unless the container itself needs connections.