Written by an AI agent working in this repository.
Every research project here commits its numbers to a results.txt and draws its figures from that file, never from retyped values. The shared helper for this is research/_shared/linefig.py: table() reads a block of a results file and write_lines() draws an SVG line plot, standard library only.
Line plots were all it drew. A result that compares categories (methods, causes, label types) needs bars, and for those every project wrote its own SVG by hand. Two run records from the last two days say so directly: one needed "a hand-written bar SVG (~70 lines)" for an effect-by-cause figure in society-lanes, another found that "a bar-style results.txt needs a custom stdlib SVG, no shared helper". A third said table() "expects numeric first columns; results rows with text labels needed a hand parser".
How common is it? Of the figure scripts under research/ that draw SVG rectangles without importing linefig, 133 mention bars or categories (grep -rl --include='*figure*.py' '<rect' research | xargs grep -L linefig | xargs grep -lE 'bar|categor' | wc -l). That count is a rough upper bound, since a rectangle can also be a background or a legend swatch, but it is a lot of repeated drawing code.
What changed
svg_bars()andwrite_bars()draw a horizontal bar chart: one row per category, one bar per series, optional(lo, hi)whiskers per bar, an optional dashed reference line, and a value label at each bar's end. The axis always includes zero, so negative effects draw to the left of it. Room for the value labels is reserved on each side, so a negative bar's label never runs into the category names. Labels are XML-escaped.table(..., xtext=True)keeps the first column as text, for category rows. Header and rule lines still drop out, because a row is kept only when every value cell is a number. Withsep="|", labels may contain spaces.
As a check, the society-lanes milestone 6f data (four crowd settings, four causes, bootstrap intervals) was redrawn with write_bars in about six lines of glue instead of that project's 40-line svg() function. The committed figure was left alone; projects can switch when they next touch a figure.
Verification
research/_shared/test_linefig.py gained seven tests (text labels with whitespace and with | tables, one bar per value, grouped bars with legend, whiskers and reference line, negative bars left of zero, escaping and a length mismatch error, and every element inside the 640 px width with six series). All 22 pass. platform/ci/main_health.py reported 272 of 272 checks passing on main before the change.