λambda draw protocol
Diagrams for three destinations: live session files, vault course notes,
and Anki cards. The failure mode this skill exists to kill: TikZ written
blind and shipped unverified. You have vision — every figure gets
rendered and looked at before it is embedded, no exceptions.
Medium decision table
| Situation |
Medium |
Why |
| Plan DAGs, quick structure inside a live session |
mermaid |
renders instantly in Obsidian/GitHub; zero toolchain; fine for arrows-and-boxes |
| Course figures and Anki cards: BNs with observed/latent shading, HMM/DBN time slices, plates, message passing |
TikZ (default) |
course-faithful notation; Anki's builtin LaTeX already renders it |
| Layout is the hard part: moral graphs, jointrees, >12 nodes, elimination orderings |
DOT → dot -Tsvg |
graphviz auto-layout beats hand-placing; optionally use the result as a layout draft for TikZ |
| Quantitative data: a time-series, a line/bar plot, a distribution, an option-payoff diagram |
mermaid xychart-beta (renders natively in the app), or a labelled ASCII/Unicode plot in a code fence |
native render, no toolchain; ASCII when the plot is small or xychart fights you — see the rules below, this is where wrong charts ship |
Quantitative charts (a chart is a claim — the trap that shipped a wrong graph)
A wrong chart is a wrong claim delivered with false confidence. On surfaces
where you cannot compile-and-LOOK (mermaid in chat, the lounge), the LOOK step
becomes a trace-every-point check you run in your head before emitting.
mermaid xychart-beta — all binding:
- x-axis category labels MUST be unique. The band axis keys on the label
string: two identical labels collapse to ONE slot, and any later point
carrying that label jumps backward onto the earlier slot. This is the
exact bug that shipped — an implied-vol series with
x-axis ["pre-Q3","Q3 print","post","pre-Q4","Q4 print","post"] rendered
its final point regressed, because the second "post" collapsed onto the
first. For repeating phases, disambiguate: post-Q3, post-Q4.
- Data length == x-axis count.
line [...] / bar [...] with N values
needs exactly N x-categories, in the same order.
- y-axis range spans the data:
y-axis "label" MIN --> MAX, MIN below the
smallest value, MAX above the largest — else points clip at the frame.
- Trace every point before shipping. Read each value against its (unique)
x-label and confirm the shape is what you meant: the monotone part is
monotone, the sawtooth actually saws, the last point sits at the last x.
This is the data-chart equivalent of the TikZ LOOK.
Prefer a labelled ASCII/Unicode plot for a quick trend, ≤ ~8 points, or
when xychart fights you: it renders everywhere (monospace code fence), cannot
collapse labels, and matches the house classical-print style. Hand-place the
marks against a labelled axis and trace them the same way, e.g.:
implied vol (pts)
58 ┤ ●
│ \ ● rebuild is slow…
42 ┤ ●______/ \
38 ┤ \ / \
37 ┤ \__/ ● ← still below, mean-reverting up into the next print
└────┬────┬────┬────┬────┬────
pre-Q3 post Q4 post-Q4
Renderer note: LambdaMind's chat and session panes render mermaid
natively (```mermaid fences). xychart-beta works there; the band-axis
label-collapse is a mermaid property, not an app bug — uniqueness is on
you. Never emit a chart you have not traced.
The TikZ loop (mandatory)
- Write the picture into the scratchpad using the standalone harness from
~/lattice/org-notes/uni/Anki.md (binding — read it first in any session
that draws for Anki):\documentclass[tikz,border=3pt]{standalone}
\usepackage{amsmath,amssymb}
\usetikzlibrary{arrows.meta,positioning,calc,backgrounds,shapes.geometric,fit}
\begin{document}
...
\end{document}
lualatex -interaction=nonstopmode -halt-on-error in the scratchpad.
pdftoppm -png -r 150 the result.
- Read the PNG and inspect it: arrowheads point the right way; no
label/edge collisions; observed nodes actually shaded; slices aligned;
nothing orphaned or overlapping. Fix and recompile.
- Budget ≤3 compile-view cycles; if it still fights you, simplify the
figure (fewer nodes, drop the plate, straight edges) rather than
fight TikZ. A clean simple figure beats a mangled ambitious one.
- Only a viewed, passing figure may be embedded or pushed to a card.
PGM drawing conventions
- Latent variables:
\node[vertex] (X1) {$X_1$}; with
vertex/.style={circle, draw, minimum size=8mm}.
- Observed variables:
observed/.style={vertex, fill=gray!30}.
- DBN/HMM time slices: one column per slice, transition arrows
horizontal, emission arrows vertical, trailing
\node {$\cdots$} for
unrolling. 2-TBN form: two slices + the inter-slice arrows only.
- Plates:
backgrounds layer + fit, label bottom-right.
- Undirected (Markov networks): plain
-- edges, no arrowheads.
- Style names: never bare English words TikZ may own (
out, in, at,
to, node, edge, every, cap have all bitten). Use vertex,
observed, slice, blanket.
- No pgfplots; hand-draw curves if ever needed.
- Course-faithful notation (check the course's own slides for symbol
conventions before labelling).
Slide excerpts (fourth tier — not drawing, extracting)
When a teaching step cites slide/page $N$ of a course PDF, show it:
pdftoppm -png -r 150 -f N -l N <pdf> <scratchpad>/slide (single page).
- If only a region matters, crop:
magick <png> -crop WxH+X+Y +repage out.png
— then view the result to confirm the crop caught the right region.
- Copy to
<vault>/sessions/assets/<lecture>-s<N>.png, embed relatively
in the session file next to the teaching step.
Course slides are copyrighted: excerpts live in the private vault only —
never in anything public, never in the OSS repo, never in shared decks.
Destinations
- Vault embed: save PNG to
<vault>/courses/<course>/figs/<name>.png
and embed relatively ( from
a session file, or wiki-embed). Keep the .tex source next to it.
- Anki card: the card carries the bare
\begin{tikzpicture}...
source (never wrapped in \[...\]) — only after the local compile
passed. All Anki.md TikZ rules binding.
- Session file quick-structure: mermaid inline; no files.
Compile hygiene
All compiles run in the scratchpad, never in the vault. Copy in only the
final PNG + tex source. If the vault is a git repo, figures ride the
session's end-of-session commit.
1---2name: lambda-draw3description: Diagram production for λambda — ANY teaching figure OR data chart, any subject. Graphical models (BNs, Markov chains, HMMs, DBNs, jointrees) AND quantitative charts (time-series, line/bar plots, distributions, option-payoff diagrams). Use for "/lambda-draw <description>" or whenever a session's teaching step needs a figure or a chart. Picks the medium (mermaid / mermaid xychart / TikZ / DOT / ASCII), enforces the compile→render→LOOK→fix loop for TikZ and a trace-every-point check for data charts; nothing unviewed or unverified is ever embedded.4---56# λambda draw protocol78Diagrams for three destinations: live session files, vault course notes,9and Anki cards. The failure mode this skill exists to kill: TikZ written10blind and shipped unverified. **You have vision — every figure gets11rendered and looked at before it is embedded, no exceptions.**1213## Medium decision table1415| Situation | Medium | Why |16|---|---|---|17| Plan DAGs, quick structure inside a live session | **mermaid** | renders instantly in Obsidian/GitHub; zero toolchain; fine for arrows-and-boxes |18| Course figures and Anki cards: BNs with observed/latent shading, HMM/DBN time slices, plates, message passing | **TikZ** (default) | course-faithful notation; Anki's builtin LaTeX already renders it |19| Layout is the hard part: moral graphs, jointrees, >12 nodes, elimination orderings | **DOT → `dot -Tsvg`** | graphviz auto-layout beats hand-placing; optionally use the result as a layout draft for TikZ |20| Quantitative data: a time-series, a line/bar plot, a distribution, an option-payoff diagram | **mermaid `xychart-beta`** (renders natively in the app), or a labelled ASCII/Unicode plot in a code fence | native render, no toolchain; ASCII when the plot is small or xychart fights you — see the rules below, this is where wrong charts ship |2122## Quantitative charts (a chart is a claim — the trap that shipped a wrong graph)2324A wrong chart is a wrong claim delivered with false confidence. On surfaces25where you cannot compile-and-LOOK (mermaid in chat, the lounge), the LOOK step26becomes a **trace-every-point check you run in your head before emitting**.2728**mermaid `xychart-beta` — all binding:**29- **x-axis category labels MUST be unique.** The band axis keys on the label30 *string*: two identical labels collapse to ONE slot, and any later point31 carrying that label jumps **backward** onto the earlier slot. This is the32 exact bug that shipped — an implied-vol series with33 `x-axis ["pre-Q3","Q3 print","post","pre-Q4","Q4 print","post"]` rendered34 its final point regressed, because the second `"post"` collapsed onto the35 first. For repeating phases, disambiguate: `post-Q3`, `post-Q4`.36- **Data length == x-axis count.** `line [...]` / `bar [...]` with N values37 needs exactly N x-categories, in the same order.38- **y-axis range spans the data:** `y-axis "label" MIN --> MAX`, MIN below the39 smallest value, MAX above the largest — else points clip at the frame.40- **Trace every point before shipping.** Read each value against its (unique)41 x-label and confirm the shape is what you meant: the monotone part is42 monotone, the sawtooth actually saws, the last point sits at the last x.43 This is the data-chart equivalent of the TikZ LOOK.4445**Prefer a labelled ASCII/Unicode plot** for a quick trend, ≤ ~8 points, or46when xychart fights you: it renders everywhere (monospace code fence), cannot47collapse labels, and matches the house classical-print style. Hand-place the48marks against a labelled axis and trace them the same way, e.g.:4950```51implied vol (pts)52 58 ┤ ●53 │ \ ● rebuild is slow…54 42 ┤ ●______/ \55 38 ┤ \ / \56 37 ┤ \__/ ● ← still below, mean-reverting up into the next print57 └────┬────┬────┬────┬────┬────58 pre-Q3 post Q4 post-Q459```6061**Renderer note:** LambdaMind's chat and session panes render mermaid62natively (```mermaid fences). `xychart-beta` works there; the band-axis63label-collapse is a mermaid property, **not an app bug** — uniqueness is on64you. Never emit a chart you have not traced.6566## The TikZ loop (mandatory)67681. Write the picture into the scratchpad using the standalone harness from69 `~/lattice/org-notes/uni/Anki.md` (binding — read it first in any session70 that draws for Anki):71 ```72 \documentclass[tikz,border=3pt]{standalone}73 \usepackage{amsmath,amssymb}74 \usetikzlibrary{arrows.meta,positioning,calc,backgrounds,shapes.geometric,fit}75 \begin{document}76 ...77 \end{document}78 ```792. `lualatex -interaction=nonstopmode -halt-on-error` in the scratchpad.803. `pdftoppm -png -r 150` the result.814. **Read the PNG and inspect it**: arrowheads point the right way; no82 label/edge collisions; observed nodes actually shaded; slices aligned;83 nothing orphaned or overlapping. Fix and recompile.845. Budget ≤3 compile-view cycles; if it still fights you, simplify the85 figure (fewer nodes, drop the plate, straight edges) rather than86 fight TikZ. A clean simple figure beats a mangled ambitious one.876. Only a viewed, passing figure may be embedded or pushed to a card.8889## PGM drawing conventions9091- Latent variables: `\node[vertex] (X1) {$X_1$};` with92 `vertex/.style={circle, draw, minimum size=8mm}`.93- Observed variables: `observed/.style={vertex, fill=gray!30}`.94- DBN/HMM time slices: one column per slice, transition arrows95 horizontal, emission arrows vertical, trailing `\node {$\cdots$}` for96 unrolling. 2-TBN form: two slices + the inter-slice arrows only.97- Plates: `backgrounds` layer + `fit`, label bottom-right.98- Undirected (Markov networks): plain `--` edges, no arrowheads.99- Style names: never bare English words TikZ may own (`out`, `in`, `at`,100 `to`, `node`, `edge`, `every`, `cap` have all bitten). Use `vertex`,101 `observed`, `slice`, `blanket`.102- No pgfplots; hand-draw curves if ever needed.103- Course-faithful notation (check the course's own slides for symbol104 conventions before labelling).105106## Slide excerpts (fourth tier — not drawing, extracting)107108When a teaching step cites slide/page $N$ of a course PDF, show it:1091101. `pdftoppm -png -r 150 -f N -l N <pdf> <scratchpad>/slide` (single page).1112. If only a region matters, crop: `magick <png> -crop WxH+X+Y +repage out.png`112 — then **view the result** to confirm the crop caught the right region.1133. Copy to `<vault>/sessions/assets/<lecture>-s<N>.png`, embed relatively114 in the session file next to the teaching step.115116Course slides are copyrighted: excerpts live in the private vault only —117never in anything public, never in the OSS repo, never in shared decks.118119## Destinations120121- **Vault embed**: save PNG to `<vault>/courses/<course>/figs/<name>.png`122 and embed relatively (`` from123 a session file, or wiki-embed). Keep the `.tex` source next to it.124- **Anki card**: the card carries the **bare** `\begin{tikzpicture}...`125 source (never wrapped in `\[...\]`) — only after the local compile126 passed. All Anki.md TikZ rules binding.127- **Session file quick-structure**: mermaid inline; no files.128129## Compile hygiene130131All compiles run in the scratchpad, never in the vault. Copy in only the132final PNG + tex source. If the vault is a git repo, figures ride the133session's end-of-session commit.