Summary
Add figure.boxplot() to display the five-number summary (min, Q1, median, Q3, max) of one or more data series, matching matplotlib's plt.boxplot().
Motivation
Box plots are the standard way to compare performance distributions across multiple implementations side-by-side without the noise of a full histogram. A single glance reveals median, spread, and outliers for each candidate.
Proposed API
// One box per series
figure.boxplot(impl_a.data(), impl_a.size(), 1.0).label("impl A");
figure.boxplot(impl_b.data(), impl_b.size(), 2.0).label("impl B");
figure.boxplot(impl_c.data(), impl_c.size(), 3.0).label("impl C");
// Or batch API:
figure.boxplot({impl_a, impl_b, impl_c}, {"impl A", "impl B", "impl C"});
The second positional argument is the X-center for the box.
Implementation Notes
Statistics to compute per series (single O(n log n) sort pass):
- min, max — first/last element after sort
- Q1, median, Q3 — index-based selection after sort (no full sort needed, nth_element)
- Whiskers: 1.5 × IQR rule (Tukey); points beyond = outliers drawn as individual markers
Rendering (all via existing Canvas primitives):
- Box:
draw_rect() from Q1 to Q3 at fixed pixel width
- Median line:
draw_line() across the box at median Y
- Whisker lines: thin vertical
draw_line() from box edges to whisker tips + horizontal caps
- Outliers:
draw_circle() for each point beyond whiskers
Acceptance Criteria
Summary
Add
figure.boxplot()to display the five-number summary (min, Q1, median, Q3, max) of one or more data series, matching matplotlib'splt.boxplot().Motivation
Box plots are the standard way to compare performance distributions across multiple implementations side-by-side without the noise of a full histogram. A single glance reveals median, spread, and outliers for each candidate.
Proposed API
The second positional argument is the X-center for the box.
Implementation Notes
Statistics to compute per series (single O(n log n) sort pass):
Rendering (all via existing
Canvasprimitives):draw_rect()from Q1 to Q3 at fixed pixel widthdraw_line()across the box at median Ydraw_line()from box edges to whisker tips + horizontal capsdraw_circle()for each point beyond whiskersAcceptance Criteria
examples/boxplot.cpp