# Visualization Guide

> **LitHermes child boundary:** This is inert Hermes reference data. A conference child has `delegation_allowed=false`, returns a bounded packet only, and never writes shared or project state; only the root chair writes approved figures.

Mandatory rules for all `results.png` figures generated by this family. Use the registered `lithermes:lit-scientific-visualization` standards.

## Setup

Every `visualize.py` MUST start with:

```python
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'scripts'))
from style_presets import rcparams
rcparams()  # MUST be called before plt.subplots()
```

This loads `scripts/style_presets.py` which sets Pretendard/Arial fonts, inward ticks, Okabe-Ito colors, white background, and DPI 600.

## 7 Mandatory Rules

### 1. Axis endpoints must show numbers
First and last tick on both axes must be visible. Use `ax.set_xlim()` and `ax.set_ylim()` explicitly.

### 2. Subplots must maintain spacing
Use `fig.tight_layout(pad=1.5)` or `constrained_layout=True`. No overlapping labels.

### 3. Legend must never obscure data
Place legend where it doesn't cover data points. Use `loc='upper right'` or `bbox_to_anchor` if needed.

### 4. No titles
Journal figures use captions, not titles. Do NOT call `ax.set_title()` or `fig.suptitle()`.

### 5. Legend text color must match data color
Each legend entry's text color matches its data series color:
```python
leg = ax.legend()
colors = ['#0072B2', '#D55E00', '#009E73']
for i, text in enumerate(leg.get_texts()):
    text.set_color(colors[i])
```

### 6. Legend border: black, framealpha=1
```python
ax.legend(frameon=True, edgecolor='black', framealpha=1)
```

### 7. DPI > 500
Save at 600 DPI. Export both PNG and PDF:
```python
fig.savefig('results.png', dpi=600, bbox_inches='tight')
fig.savefig('results.pdf', dpi=600, bbox_inches='tight')
```

## Figure Structure for Autoresearch

Two-panel layout with panel labels:

```python
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8))

# Panel labels
ax1.text(-0.08, 1.08, 'A', transform=ax1.transAxes, fontsize=16, fontweight='bold', va='top')
ax2.text(-0.08, 1.08, 'B', transform=ax2.transAxes, fontsize=16, fontweight='bold', va='top')
```

**Panel A — Metric Convergence:**
- Scatter: kept iterations (blue `#0072B2`) vs reverted (vermillion `#D55E00`)
- Line: best-so-far envelope (green `#009E73`)
- Dashed: target threshold (orange `#E69F00`)
- Annotate baseline and best values

**Panel B — Domain-specific result:**
- Code optimization: bar chart of execution times
- Function fitting: prediction curve vs data scatter
- Literature review: category coverage
- Skill elaboration: component breakdown

## Okabe-Ito Palette Reference

| Color | Hex | Use |
|-------|-----|-----|
| Orange | `#E69F00` | Target line, warnings |
| Sky Blue | `#56B4E9` | Train data, secondary |
| Bluish Green | `#009E73` | Best-so-far, success |
| Yellow | `#F0E442` | Highlights |
| Blue | `#0072B2` | Kept iterations, primary |
| Vermillion | `#D55E00` | Reverted, errors |
| Reddish Purple | `#CC79A7` | Prediction curves |
| Black | `#000000` | Baselines, text |

## Conference-Specific Panels

For autoconference visualizations, use multi-panel layouts:

**Panel A:** Per-researcher metric convergence (one line per researcher, different colors)
**Panel B:** Best-of-conference envelope (across all researchers)
**Panel C:** Peer review verdict distribution (validated/challenged/overturned per round)
**Panel D (optional):** Researcher strategy heatmap or cross-pollination graph
