/paper-figure:paper-figurefrom paper-figure
Author a publication figure as an editable vector artifact — a paper's Figure 1 or method schematic, an architecture or pipeline diagram, a concept panel — emitting layered SVG, a flat fully-editable PPTX, and a print PDF from one Python display list, with a render-and-look review loop and programmatic layout lint.
Ships in paper-figure. 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.
Author once in Python; get a layered SVG, a flat editable PPTX, and a print PDF that cannot drift from each other. Drawing calls append to a display list — a plain JSON tree — and every backend replays that same tree.
This exists because the two obvious approaches both fail. Matplotlib cannot produce an
editable schematic: with svg.fonttype='none' plain labels survive, but mathtext is
exploded into per-glyph <tspan>s in non-reading order, and \mathcal{L} comes out as
private-use codepoint U+E238 in a font that is not installed system-wide — a tofu box in
any renderer but matplotlib's own. And hand-written SVG fails differently: an LLM cannot
compute text advance width, so labels collide.
figkit fixes both: it measures real font files for every run, and it emits geometry
rather than trusting any renderer's text layout.
Five steps, in this order. Steps 3 and 4 are not optional.
SKILL="${CLAUDE_SKILL_DIR}"
# 1. scaffold (or write the figure script by hand)
uv run "$SKILL/scripts/new_figure.py" figures/fig1_method.py --title "Method overview"
# 2. build -> figures/fig1_method.svg + .json
PYTHONPATH="$SKILL/scripts" uv run figures/fig1_method.py
# 3. lint the geometry — arithmetic, not judgement
uv run "$SKILL/scripts/lint.py" figures/fig1_method.json
# 4. rasterize, then READ the PNGs with the Read tool and look at them
uv run "$SKILL/scripts/render.py" figures/fig1_method.svg
# 5. once it looks right, emit the editable deck
uv run "$SKILL/scripts/to_pptx.py" figures/fig1_method.json
Iterate 3 → 4 → fix → repeat. Three to five rounds is normal for a full-width figure; each round fixes things that are only visible once rendered.
Steps 3–4 are the reason this works. Layout defects are found by looking, not by reasoning about coordinates. Every real defect in practice — a callout sitting on top of a scatter, a legend colliding with an axis label, a highlight box covering the neighbour column's text — was invisible in the code and obvious in the PNG.
render.py writes one PNG per available engine. Read all of them. A defect present in
one engine and absent in another is a portability bug, not a layout bug — see
references/renderers.md for what each engine breaks.
Never judge a .pptx by its Finder/QuickLook preview: QuickLook cannot draw custGeom
freeforms and shows blank where curves are perfectly fine. render.py routes .pptx
through Keynote (or LibreOffice) instead.
from figkit import Figure
fig = Figure(1580, 840)
P = fig.P # the house palette
with fig.layer("panel_a", "Panel a — hypothesis 1"):
with fig.group("a1_corpus"):
fig.frame(40, 120, 132, 250, "Pretraining corpus", "a1", P["neutral"])
fig.text(106, 320, ["10", ("4", "sup"), "× standard"], size=12.5,
fill=P["gray_2"], gid="a1_cap")
fig.arrow(180, 245, 214, 245, gid="arrow_corpus_to_clusters",
connect={"from": "a1_bg", "to": "a2_bg"})
fig.save("figures/fig1_method") # writes .svg and .json
Rich text is a list of parts. A part is a plain string, or (text, style) where style
combines i italic, b bold, sub, sup, isub italic-subscript, sym symbol-font
fallback for glyphs Helvetica lacks (∝). Sub/superscripts become their own positioned
runs — never dy-chained tspans, which scramble in cairo.
connect={"from": id, "to": id} binds an arrow to those shapes' connection sites, so in
PowerPoint dragging a box drags its arrows with it. Without it the arrow is static and
strands in mid-air when the box moves. (Technique from tsinghua-fib-lab/LiveFigure.)
Two complete figures, end to end:
Full API: references/api.md. House style — palette semantics, type scale, layout grammar: references/design-system.md. What figure to make and why — figure roles by venue, colour-blind-safe encoding, data-ink: references/figure-craft.md.
PPTX is the preferred deliverable. It is where the last 10% of a figure actually gets done — nudging a label, resizing a box, trying a different arrangement — and it needs no vector-editor licence. Produce it by default; treat the others as companions.
| File | What it is | Edit it in |
|---|---|---|
.pptx | Primary. Native shapes — selectable, named, editable in place | PowerPoint, Keynote |
.svg | Layered master. Named layers, semantic id on every element, live <text> | Illustrator, Figma, Inkscape |
.pdf | Vector, fonts embedded, text extractable | LaTeX \includegraphics |
.json | The display list. The source of truth every backend replays | — |
Fine granularity is not free — 278 loose shapes is the right answer for one figure and the wrong answer for the other five.
to_pptx.py emits. You will
rearrange this figure many times; each box, arrow and label has to move on its own.--grouped so each panel arrives as one object, or — better — make it in
matplotlib/seaborn and place the exported PDF as a single picture. Both keep the slide
navigable instead of burying the reader in hundreds of shapes.frame() supports this either way: it gives the visual affordance of grouping with a
background rectangle, so a flat figure still reads as grouped without anything to
un-group.
PDF comes from the SVG: rsvg-convert -f pdf fig.svg -o fig.pdf, or
uv run --with cairosvg python -c "import cairosvg,sys;cairosvg.svg2pdf(url=sys.argv[1],write_to=sys.argv[2])" fig.svg fig.pdf.
var(). librsvg does not support custom properties and
collapses an unresolved var() to solid black — the whole figure goes dark. Recolour
by editing the palette in the generator and re-running.compare types of renders as
typesof. figkit carries boundary gaps as geometry; keep it that way.pdf.fonttype=42 if any matplotlib panel is involved. The default is Type 3,
which several venues reject.fig.measure(text, size, weight, style).
PowerPoint and Keynote set Helvetica about 18% wider than the metrics, which is why
lint.py defaults to --slack 1.18.Use this for the hard end of the figure gradient — a custom-drawn schematic, typically Figure 1. Results panels (grouped bars, trends, heatmaps) are better made with matplotlib or seaborn and composed in; redrawing them as figkit primitives buys nothing.
Externally-rendered content — protein structures, microscopy, screenshots — is not generated here; place it as an image and compose around it. Hand-drawn illustration is out of scope. Figure quality comes from iterating on the render, not from one pass.
uv is the only prerequisite. Every script carries PEP 723 inline metadata, so
uv run provisions its dependencies per-run — nothing is installed globally and there
is no virtualenv to activate (activation state is exactly what an agent cannot track).
uv run "$SKILL/scripts/render.py" --probe reports which rasterizers exist here.
At least one SVG engine is needed: rsvg-convert (brew install librsvg), cairosvg,
or macOS qlmanage. For .pptx preview: Keynote on macOS, or LibreOffice.
Setup, permissions, and how this is packaged: references/setup.md.
examples/fig1_transunet.preview.png (opens in a new tab)examples/fig1_transunet.py (opens in a new tab)examples/fig1_transunet.svg (opens in a new tab)examples/fig2_outcome_curve.preview.png (opens in a new tab)examples/fig2_outcome_curve.py (opens in a new tab)examples/fig2_outcome_curve.svg (opens in a new tab)references/api.md (opens in a new tab)references/design-system.md (opens in a new tab)references/figure-craft.md (opens in a new tab)references/renderers.md (opens in a new tab)references/setup.md (opens in a new tab)scripts/figkit.py (opens in a new tab)scripts/lint.py (opens in a new tab)scripts/new_figure.py (opens in a new tab)scripts/render.py (opens in a new tab)scripts/to_pptx.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
flagship figure, Figure 1, method figure, method overview, teaser figure, schematic, architecture diagram, pipeline diagram, boxes and arrows, concept figure, editable figure, vector figure, figure for a paper, diagram I can edit in Illustrator / Figma / Inkscape / PowerPoint / Keynote, SVG diagram, PPTX diagram.
Other plugins' skills for the same job
npx claudepluginhub tomtommyyuan/paper-figure-skill --plugin paper-figure