/figures:scientific-figurefrom figures
Composes multi-panel scientific figures at exact journal dimensions (Nature, Science, Cell, PNAS) using svgutils. Validates font sizes against journal minima and exports PDF/PNG via Inkscape or cairosvg.
Ships in figures. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Compose publication-quality multi-panel figures at exact journal dimensions (mm/pt), validate font sizes against journal minima before export, and write PDF/PNG that the journal will accept without resize.
The previous react-pdf workflow had two structural failures:
This skill replaces that workflow. Panels are placed at exact mm coordinates, text is preserved as SVG <text> elements so font sizes are inspectable before export, and the validator rescales individual panels rather than the whole figure when a font minimum is violated.
1. Plan 2. Build elements 3. Compose 4. Validate fonts 5. Export
(journal (matplotlib/seaborn (svgutils, at (per-element pt vs (Inkscape if
size, panel per panel; SVG out; exact mm/pt; journal minimum; present;
grid) optional icons) text preserved) rescale panel if cairosvg
below minimum) otherwise)
Every step uses on-the-fly execution via uv run --with so no permanent installs are required for the skill itself.
Before generating anything, fix the following:
references/journal-specs.md for the full table; the four most common are summarized below.references/color-palettes.md and reuse across all panels.| Journal | 1 column | 2 column | Min body font | Notes |
|---|---|---|---|---|
| Nature | 89 mm | 183 mm | 5 pt | 8 pt for panel labels |
| Science | 55 mm | 120 mm | 6 pt | Myriad/Helvetica preferred |
| Cell | 85 or 112 mm | 174 mm | 6 pt | Max 225 mm tall |
| PNAS | 87 mm | 180 mm | 6 pt | No label below 2 mm tall |
The validator in step 4 enforces these. Pick the journal early so the validator can warn early.
Each panel is generated independently as an SVG. Common sources:
bbox_inches='tight', transparent=True, format='svg'. See the figures:plot-styling skill for the library decision tree and SciencePlots recipes.figures:transparent-icons skill.figures:svg-primitives (auto-fit boxes, validated arrows, layered z-order); for hand-authored SVG patterns see figures:svg-figure.Save each element to a working directory (typically panels/), then compose them in step 3.
The composer is built around svgutils (MIT license; uv run --with svgutils). It places panels at exact mm coordinates and preserves text as inspectable SVG <text> elements.
Two ways to compose: the Figure helper in scripts/compose.py (most cases) and direct svgutils.compose for full control.
uv run --with svgutils --with lxml python scripts/compose.py panels-config.json -o figure.svg
panels-config.json schema:
{
"width_mm": 183,
"height_mm": 120,
"journal": "nature",
"panels": [
{"id": "A", "src": "panels/spectrum.svg", "x_mm": 0, "y_mm": 0, "scale": 0.5, "label": "A"},
{"id": "B", "src": "panels/topomap.svg", "x_mm": 92, "y_mm": 0, "scale": 0.5, "label": "B"},
{"id": "C", "src": "panels/timecourse.svg", "x_mm": 0, "y_mm": 60, "scale": 1.0, "label": "C", "width_mm": 183}
]
}
Panel labels (A, B, C) are placed at top-left of each panel in 12 pt bold sans-serif.
from svgutils.compose import Figure, SVG, Panel, Text
fig = Figure(
"183mm", "120mm",
Panel(
SVG("panels/spectrum.svg").scale(0.5),
Text("A", 5, 15, size=12, weight="bold"),
).move(0, 0),
Panel(
SVG("panels/topomap.svg").scale(0.5),
Text("B", 5, 15, size=12, weight="bold"),
).move(92, 0),
)
fig.save("figure.svg")
See references/composition-workflow.md for the patterns (panel scaling, label placement, scale bars, multi-panel grid utilities).
This is the step that prevents the journal-rejection scenario. Run:
uv run --with lxml python scripts/validate_fonts.py figure.svg --journal nature
The validator parses every <text> and <tspan> element with a font-size, walks the accumulated transform stack to compute the effective font size at the final physical dimensions, and reports anything below the journal minimum. Output is JSON:
{
"svg": "figure.svg",
"journal": "nature",
"minimum_pt": 5.0,
"checked_count": 47,
"skipped_count": 0,
"issue_count": 1,
"issues": [
{
"text": "Frequency (Hz)",
"specified_pt": 9.0,
"effective_pt": 4.5,
"scale_x": 0.5,
"scale_y": 0.5,
"minimum_pt": 5.0,
"tag_id": ""
}
]
}
skipped_count counts text elements where no font-size could be resolved (CSS class selectors, inherited styles). Exit codes: 0 clean, 1 issues found, 2 script error (malformed SVG, missing file).
If a panel is the culprit (its .scale() is too small), three remedies:
See references/font-validation.md for the full mechanics and rationale.
uv run --with cairosvg python scripts/export.py figure.svg --out figure.pdf --dpi 300
export.py detects Inkscape on $PATH at runtime. When present, Inkscape produces the highest-fidelity PDF (text remains text, fonts subsetted). When absent, the script falls back to cairosvg with a stderr warning that text without an installed font may be converted to paths or skipped.
brew install inkscape # macOS
sudo apt install inkscape # Debian/Ubuntu
brew install inkscape is a single line and a ~200 MB one-time cost; once installed the script auto-detects it. The cairosvg fallback works without Inkscape but produces lower-fidelity PDFs when journal-required fonts are not installed.
Generate a figure caption that:
The figures:figure-qa agent proactively runs on the composed SVG to check geometric correctness, alignment, color-palette compliance, and label legibility. The agent invokes validate_fonts.py for the font-size pass under the hood and the SVG branch's palette and geometry checks alongside.
references/composition-workflow.md — svgutils patterns and idiomsreferences/font-validation.md — pt minimum mechanics, transform-stack mathreferences/journal-specs.md — full table of journal dimensions and font rulesreferences/color-palettes.md — colorblind-safe palettes (Wong, Okabe-Ito, viridis, Crameri)scripts/compose.py — svgutils composer (CLI + library)scripts/validate_fonts.py — font-size validatorscripts/export.py — Inkscape/cairosvg exporterexamples/two-column-figure.py — end-to-end working example (matplotlib panels → compose → validate → export)examples/two-column-figure.py (opens in a new tab)examples/validate_failure_case.py (opens in a new tab)references/color-palettes.md (opens in a new tab)references/composition-workflow.md (opens in a new tab)references/font-validation.md (opens in a new tab)references/journal-specs.md (opens in a new tab)scripts/compose.py (opens in a new tab)scripts/export.py (opens in a new tab)scripts/validate_fonts.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub neuromechanist/research-skills --plugin figures8 skills in this plugin
/ai-full-figureUse this skill when the user asks to "generate an AI figure", "make an AI-generated figure", "make a poster figure", "make a presentation figure", "generate a figure with AI", "generate figure panels with Codex", "make a multi-panel AI figure", "AI background for a figure", or wants a pictorial figure or panel (brain scene, apparatus, anatomy, pipeline illustration) rendered by gpt-image-2 through the Codex CLI with large verbatim titles and panel letters, then QA'd and iterated until it passes. Expects a theme from figures:figure-bible. Data plots, axes, numerals, and equations go to figures:plot-styling or figures:svg-primitives instead./figure-bibleUse this skill when the user asks to "make a figure bible", "set up a style bible", "create a figure theme", "make a theme for my figures", "set up a figure style", "palette for my paper figures", or wants a consistent figure style. Scaffolds and validates figures/theme.json; run before any figures skill generates images./figure-qaUse this skill to QA a scientific figure for journal compliance, alignment, palette correctness, and text legibility. Triggers on "QA this figure", "check this figure", "review my figure", "is this figure paper-ready", "validate figure", "check the text in this figure", or when invoked after a figures skill produces output (unless the caller passes no-qa). Dispatches on input type (SVG, raster PNG/JPG/TIFF, Python plot script, or composed-figure directory), runs the programmatic checks including OCR of expected strings and palette compliance against the project theme, adds a vision rubric pass, and returns a report with a machine-readable JSON verdict that drives the generate, QA, fix loop./plot-stylingThis skill should be used when the user asks to "plot data", "make a plot for a paper", "make a publication plot", "create a journal-quality plot", "matplotlib for a figure", "use seaborn", "use plotnine", "use ggplot in Python", "improve plot quality", "style my plot", "clean up my figure", "my matplotlib plot looks ugly", "apply journal style to existing script", "fix matplotlib defaults", "use SciencePlots", "make a Nature-style plot", "make an IEEE-style plot", "make a paper-ready chart", "which plotting library should I use", or wants guidance on choosing between matplotlib / seaborn / plotnine / plotly / pyvista and applying journal-quality defaults. Produces SVG-output Python scripts whose panels are consumed by the scientific-figure composer./svg-figureThis skill should be used when the user asks to "create an SVG figure", "make a schematic", "draw a diagram", "create a schematic diagram", "draw a flowchart", "draw a process flow", "draw a workflow", "draw a workflow diagram", "make an SVG schematic", "create a process diagram", "create a pipeline diagram", "create a block diagram", "draw a system diagram", "system architecture diagram", "make this SVG editable in Illustrator", "prepare an SVG for Affinity Designer", "editor handoff", "Illustrator-friendly SVG", "hand off a figure to a designer", or wants a hand-authored or programmatic SVG with shapes, arrows, and labels that the figure-qa agent can verify. **For new Python-driven figures, route to `figures:svg-primitives` instead**, this skill is the conventions and hand-authoring reference. Outputs are SVG files that can be loaded as panel sources by the scientific-figure composer; `scripts/editor_prep.py` rewrites any finished SVG into the editor-safe dialect for Illustrator/Affinity handoff./svg-primitivesUse when the user asks to build a programmatic SVG schematic in Python: flowcharts, boxes and arrows, auto-fit SVG text, mm-precise diagrams, edge-snapped arrows, tangent-correct curve arrowheads, orthogonal or Manhattan routing, deterministic z-order layers, labeled groups, bracket groupings, leader-line annotations, or strict Canvas.save validation for text overflow. Use figure-qa instead for after-the-fact validation of arbitrary hand-authored or exported SVGs. Built on drawsvg, svgpathtools, and fontTools; output SVGs can be composed by scientific-figure.Other plugins' skills for the same job