Summary
Add a bar() API for vertical (and optionally horizontal) bar charts — the standard matplotlib plt.bar() / plt.barh() equivalent.
Motivation
Bar charts are the go-to visualization for comparing benchmark results across named implementations (e.g., "impl A vs impl B vs impl C" measured in nanoseconds). This is one of the core use-cases stated in the project motivation.
Proposed API
// Vertical bars
std::vector<double> positions = {0, 1, 2, 3};
std::vector<double> heights = {120.5, 98.3, 140.1, 88.7};
figure.bar(positions.data(), heights.data(), 4)
.color(sepia::Color{100, 180, 255})
.width(0.6) // bar width in data units
.label("throughput (ops/s)");
// Horizontal bars
figure.barh(positions.data(), heights.data(), 4)
.label("latency (ns)");
Implementation Notes
- New
BarEntry struct (or reuse PlotEntry with a PlotType enum tag)
- Rendering: for each bar, call
canvas.fill_rect() from y=0 (or x=0 for barh) to the data value, transformed through CoordTransform
- Need to store bar width (in data units) separately from line width
- Baseline is configurable (default
0.0) to support waterfall-style charts later
TickEngine already produces nice tick labels — axis labels should auto-fit to bar positions
Acceptance Criteria
Summary
Add a
bar()API for vertical (and optionally horizontal) bar charts — the standard matplotlibplt.bar()/plt.barh()equivalent.Motivation
Bar charts are the go-to visualization for comparing benchmark results across named implementations (e.g., "impl A vs impl B vs impl C" measured in nanoseconds). This is one of the core use-cases stated in the project motivation.
Proposed API
Implementation Notes
BarEntrystruct (or reusePlotEntrywith aPlotTypeenum tag)canvas.fill_rect()fromy=0(orx=0forbarh) to the data value, transformed throughCoordTransform0.0) to support waterfall-style charts laterTickEnginealready produces nice tick labels — axis labels should auto-fit to bar positionsAcceptance Criteria
bar()renders filled rectangles at correct screen coordinatesbarh()renders horizontal variantexamples/bar_chart.cpp