# Figures and tables

A figure exists to show a claim. If a reader cannot state the finding from the figure and its caption alone, redesign the figure.

## Principles

1. **One message per figure.** Multi-panel figures share one message across panels (**a**, **b**, **c**).
2. **The headline figure shows the main claim.** Usually Fig. 1 or Fig. 2. It appears in Results, not Introduction.
3. **Show the data, not only the summary.** Points or distributions beside means where `n` is small.
4. **Uncertainty is visible.** Error bars, bands, or intervals on every estimate, defined in the caption (s.d., s.e.m., 95% CI, and `n`).
5. **No decoration.** No 3D, no gradients, no drop shadows, no dual y-axes, no pie charts, no rainbow colour maps.
6. **Axes start at zero for bars.** Lines and points may zoom; say so in the caption if it could mislead.
7. **Label directly** where possible instead of relying on a legend.

## Colour

Use the Okabe–Ito palette, in this order. It is distinguishable under the common forms of colour-vision deficiency and in greyscale.

| Role | Name | Hex |
| --- | --- | --- |
| 1 | Blue | `#0072B2` |
| 2 | Vermilion | `#D55E00` |
| 3 | Bluish green | `#009E73` |
| 4 | Orange | `#E69F00` |
| 5 | Sky blue | `#56B4E9` |
| 6 | Reddish purple | `#CC79A7` |
| 7 | Yellow | `#F0E442` |
| 8 | Black | `#000000` |

Sequential data: `viridis`. Diverging data: `RdBu` centred on the meaningful zero. Never encode a category with colour alone; vary marker shape or line style as well.

## Technical specification

| Property | Requirement |
| --- | --- |
| Format | SVG preferred. PNG accepted at ≥ 2× (≥ 300 dpi at print size). No JPEG for plots. |
| Width | 89 mm (single column) or 183 mm (double column). Height ≤ 170 mm. |
| Fonts | Sans-serif (Helvetica, Arial, DM Sans). Minimum 7 pt at final size; axis labels 8 pt; panel letters 10 pt bold lowercase. |
| Lines | ≥ 0.5 pt. Data lines 1 to 1.5 pt. |
| Panel labels | Lowercase bold **a**, **b**, **c** at top-left of each panel. |
| Axes | Labelled with quantity and unit: `Latency (ms)`. No titles inside the panel; the caption is the title. |
| Text in figure | Editable text in SVG (do not outline fonts). |
| Background | White or transparent. No frame around the whole figure. |
| File names | `figures/fig1.svg`, `figures/fig2.png`, `figures/ed-fig1.svg`. |

## Captions

The Markdown alt text is the caption. Form:

```
![Fig. 2 | Sparse routing reduces latency without loss of accuracy. a, Latency per token versus number of active experts (n = 5 seeds; points, individual runs; line, mean; band, 95% CI). b, Accuracy on the held-out set for the same runs. Dashed line, dense baseline. Statistics: two-sided Welch's t-test, p = 0.004.](figures/fig2.svg)
```

- Start with `Fig. N |` then a **title in bold sense** (a declarative sentence, no full stop needed), then a full stop.
- Describe each panel, prefixed with its bold letter.
- Define every symbol, line, and error bar. State `n` and what it counts.
- Name the statistical test and give the p-value or CI.
- The caption must make sense without the main text.

## Producing figures

### matplotlib

```python
import matplotlib.pyplot as plt

OKABE_ITO = ["#0072B2", "#D55E00", "#009E73", "#E69F00", "#56B4E9", "#CC79A7", "#F0E442", "#000000"]

plt.rcParams.update({
    "figure.figsize": (3.5, 2.6),        # 89 mm single column
    "figure.dpi": 150,
    "savefig.dpi": 300,
    "font.family": "sans-serif",
    "font.size": 8,
    "axes.labelsize": 8,
    "axes.titlesize": 8,
    "xtick.labelsize": 7,
    "ytick.labelsize": 7,
    "legend.fontsize": 7,
    "legend.frameon": False,
    "axes.spines.top": False,
    "axes.spines.right": False,
    "axes.prop_cycle": plt.cycler(color=OKABE_ITO),
    "lines.linewidth": 1.2,
    "errorbar.capsize": 2,
    "svg.fonttype": "none",              # keep text editable
})

fig, ax = plt.subplots()
# … plot …
ax.set_xlabel("Active experts")
ax.set_ylabel("Latency (ms)")
ax.text(-0.18, 1.02, "a", transform=ax.transAxes, fontsize=10, fontweight="bold")
fig.tight_layout()
fig.savefig("figures/fig2.svg")
```

### Vega-Lite

Acceptable for interactive supplementary figures. Export a static SVG for the paper. Use the same palette via `"scale": {"range": [...]}`.

## Diagrams

Schematics and pipelines are SVG drawn to the same rules: sans-serif text, ≥ 7 pt, palette above, no decoration. Every box has a noun label; every arrow has a direction and, if not obvious, a verb.

## Tables

- Markdown (GFM) tables for ≤ 8 rows and ≤ 6 columns. Larger tables go in `supplementary/` as CSV with a README row describing columns and units.
- Number tables in order of citation; caption above the table in the form `Table 1 | Title.` as a paragraph immediately preceding it.
- Right-align numbers; keep decimal places consistent within a column; include units in the header (`Latency (ms)`).
- Report uncertainty in its own column or as `mean ± s.d.` with the definition in the caption.
- Bold the best value only if "best" is defined in the caption.
