# Default charts on real tables: what breaks, and what a vision model catches

When a charting library draws real official tables with its default settings, how often is the result measurably
broken, and how many of those defects does a vision model catch when asked to review the chart? This study draws 200
Statistics Canada tables three ways with matplotlib's defaults (600 charts), measures overlapping and clipped text
exactly from the renderer's own text boxes, and scores two vision models against that measurement, reporting each
model's catch rate and false-alarm rate together. The page is `index.html`.

## Data

Statistics Canada tables through its Web Data Service (https://www150.statcan.gc.ca/t1/wds/rest/), under the
Statistics Canada Open Licence (https://www.statcan.gc.ca/en/terms-conditions/open-licence). Adapted from Statistics
Canada, the tables listed in `data/sample.json`, latest periods available when the sample was drawn. This does not
constitute an endorsement by Statistics Canada of this product.

`data/tables/` holds the small extract drawn from each table (category names, values, periods, unit), so every chart
can be redrawn without the service, with one exception: the extract of table 23100058 is left out of the public
download, because one of its category names contains an ordinary word that the site's name check refuses. Its three
charts' measurements, model replies and gallery image are in the download; redrawing them needs the service.
`data/sample.json` records the seed, the sha256 of the table list used, and every
table tried with the reason any was skipped.

## Reproduce

Python 3.12 with matplotlib 3.10 and numpy. No key and no network are needed after the extracts.

```
python3 -B tests/test_charts.py                 # the checker, the reply parser, the stored results
python3 -I -B tools/render_all.py /path/to/png/dir   # redraw and re-measure all 600 charts (byte-identical PNGs)
python3 -I -B tools/review.py --replay          # every model reply re-parsed and matched to its measured chart
python3 -I -B tools/score.py                    # results/summary.json, predictions scored as declared
python3 -I -B tools/gallery.py                  # the gallery PNGs, checked byte-identical to the measured charts
python3 -I -B site/render.py                    # the page
```

`tools/get_tables.py` draws the sample from the service again. The service's latest periods move, so a fresh draw
gives different extracts. The model calls cannot be re-run from this download; `cache/` holds the model replies, which the
commands above score.

## Files

- `tools/charts.py`: the three chart specifications and the checker (text boxes from the renderer, overlap, clipping,
  the ink check). The definitions and thresholds are fixed there and on the page's Method section.
- `tools/render_all.py`: draws and measures every chart into `results/geometry.jsonl` (one record per chart, every
  visible text box, every overlapping pair and clipped box).
- `tools/review.py`: the prompt, the reply parser and the replay check over `cache/`.
- `tools/score.py`: catch and false-alarm rates with Wilson 95% intervals, per model, defect type and chart
  specification, and the gallery pick.
- `tools/gallery.py`: redraws the gallery charts into `gallery/`.
- `tools/unit_audit.py`, `results/change2-units.json`: the unit check, decided after the results: which charts put
  categories with different units on one axis (17 of 600), from the service's metadata.
- `tools/changes.py`, `results/changes-r1.json`: the changes decided after the results (intervals that allow for the table,
  as Wilson on the effective number of charts; rates without the mixed-unit charts, the right-type catch rate, the paired comparison on subtle overlaps).
  `results/summary.json` stays the frozen, declared scoring.
- `results/page-check.json`: the checker applied to this page's own charts at 390 and 1366 px.
- `predictions-r1.json`: the predictions, verbatim as committed before the sample was drawn.
- `assumptions.json`: the money assumptions behind the page's "What it is worth" section, set after the results.
- `site/render.py`, `site/page.css`: the page. Every number on it comes from `results/`, `cache/` or
  `assumptions.json`, and the claims the text makes are asserted in `render.py`.
- `vendor/viz-design-system/`: the chart kit (version 2.3.0) with its licences.

Some files are packed in default-chart-defects-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
