Skip to content

feat: aa.plot_comparison — grouped comparison barplot with value labels + chance line #311

Description

@breimanntools

Part of #305.

Problem

The "benchmark result" figure — grouped method × condition accuracy bars with
value labels and a chance line — is built entirely by hand in γ-secretase cell
28: manual x ± w/2 offsets, a per-bar ax.text annotation loop, and a manual
axhline(50) chance line:

b1 = ax.bar(x - w/2, res_scale, w, label="Scale-based", color="tab:gray")
b2 = ax.bar(x + w/2, res_cpp,   w, label="CPP",         color="tab:red")
ax.axhline(50, ls="--", color="black", lw=1)
for bars in (b1, b2):
    for b in bars:
        ax.text(b.get_x()+b.get_width()/2, b.get_height()+1, f"{b.get_height():.0f}", ...)

This grouped-comparison-with-baseline figure recurs across the paper.

Goal

Provide aa.plot_comparison(df_eval, baseline=50, annotate=True, ...) that draws
a grouped barplot from a tidy eval frame with per-bar value labels and an
optional chance/baseline line — one call replacing the manual matplotlib.

Requirements

  • aa.plot_comparison(df_eval, group=..., condition=..., value=..., baseline=50, annotate=True, ax=None)
    returning the Axes.
  • Auto bar offsets/widths for N groups; optional value labels; optional
    baseline line with a label.
  • House colors via plot_get_clist; follows plotting.md.
  • numpydoc + Examples include.

KPIs / Acceptance criteria

  • Re-authoring cell 28 on top of it removes the manual offset/annotation/
    axhline code and renders an equivalent grouped barplot.
  • ≥1 unit test (bar count = groups × conditions; baseline drawn when set;
    bad input → ValueError).

Scope / non-goals

Dependencies

Standards checklist

  • CONFIRM-FIRST (__init__.py/__all__) · plotting.md compliance · numpydoc
    · tests · no-print

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions