Skip to content

feat(matplotlib): implement scatter-regression-linear - #10132

Merged
MarkusNeusinger merged 5 commits into
mainfrom
implementation/scatter-regression-linear/matplotlib
Aug 5, 2026
Merged

feat(matplotlib): implement scatter-regression-linear#10132
MarkusNeusinger merged 5 commits into
mainfrom
implementation/scatter-regression-linear/matplotlib

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Implementation: scatter-regression-linear - python/matplotlib

Implements the python/matplotlib version of scatter-regression-linear.

File: plots/scatter-regression-linear/implementations/python/matplotlib.py

Parent Issue: #1821


🤖 impl-generate workflow

Regen from quality 93. Addressed:
- Step 0 canvas contract: previous figsize=(16,9) + default dpi + savefig(bbox_inches="tight") drifted off the 3200x1800 target; switched to the canonical figsize=(8, 4.5), dpi=400, no bbox_inches="tight"
- Rescaled all chrome to the DPI-based sizing table (title 12pt, axis labels 10pt, ticks/legend 8pt, annotation 9pt) to match the new canvas — previous 24/20/16/18pt values were tuned for the old oversized canvas
- Added an x-axis rug plot via a blended transform (matplotlib.transforms.blended_transform_factory) to show the marginal study-hours distribution, addressing the "explore additional distinctive matplotlib features (transformations, custom artists)" note
- Added x-axis grid (previously y-only) per the style guide's "both axes for scatter plots" convention
- Kept: Okabe-Ito-derived Imprint colors, 95% CI band, regression equation/R² annotation, theme-adaptive chrome, realistic study-hours/exam-score data generation
@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): Warm off-white (#FAF8F1) background. Title "scatter-regression-linear · matplotlib · anyplot.ai" in dark ink, clearly readable. Axis labels "Study Hours (hrs)" / "Exam Score (points)" dark and legible; tick labels soft gray. Grid lines subtle on both axes. Brand-green scatter points (alpha ~0.7) with a lavender regression line and matching translucent CI band; a green rug plot along the bottom shows the marginal x-distribution. Equation/R² annotation box top-left, legend bottom-right — both readable, neither overlaps data. All text is readable against the light background.

Dark render (plot-dark.png): Warm near-black (#1A1A17) background. Title, axis labels, and tick labels render in light ink — all clearly readable, no dark-on-dark failures anywhere (title, axes, ticks, legend, annotation box all pass). Data colors are identical to the light render: brand green scatter, lavender regression line and CI band, green rug ticks — confirming only chrome flipped.

Both renders pass the theme-readability check.

Score: 89/100

Category Score Max
Visual Quality 29 30
Design Excellence 13 20
Spec Compliance 14 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 8 10
Total 89 100

Visual Quality (29/30)

  • VQ-01: Text Legibility (8/8)
  • VQ-02: No Overlap (6/6)
  • VQ-03: Element Visibility (5/6) - marker size s=100 is at the floor of the recommended 100-200 range for n=80 points; a few clusters blur together
  • VQ-04: Color Accessibility (2/2)
  • VQ-05: Layout & Canvas (4/4)
  • VQ-06: Axis Labels & Title (2/2)
  • VQ-07: Palette Compliance (2/2)

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) - Thoughtful secondary color, refined annotation callout, theme-matched marker edges; above default but not publication-tier
  • DE-02: Visual Refinement (4/6) - Spines removed, subtle grid, generous whitespace; good but not flawless
  • DE-03: Data Storytelling (4/6) - Equation + R² annotation and CI shading create a clear narrative, though a fairly standard regression presentation

Spec Compliance (14/15)

  • SC-01: Plot Type (5/5)
  • SC-02: Required Features (4/4)
  • SC-03: Data Mapping (3/3)
  • SC-04: Title & Legend (2/3) - Title is missing the required "python" language segment

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6)
  • DQ-02: Realistic Context (5/5)
  • DQ-03: Appropriate Scale (4/4)

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3)
  • CQ-02: Reproducibility (2/2)
  • CQ-03: Clean Imports (2/2)
  • CQ-04: Code Elegance (2/2)
  • CQ-05: Output & API (1/1)

Library Mastery (8/10)

  • LM-01: Idiomatic Usage (5/5)
  • LM-02: Distinctive Features (3/5) - The blended-transform rug plot is genuinely distinctive; the rest is fairly generic scatter+regression code

Score Caps Applied

  • None

Strengths

  • Rug plot along the bottom axis (via blended_transform_factory) adds the marginal x-distribution — a sophisticated matplotlib transforms technique that goes beyond a basic scatter+regression.
  • Confidence-interval band uses a correct t-distribution standard-error formula and renders as a clean, semi-transparent lavender fill that never obscures the underlying points.
  • Correct Imprint palette usage: brand green (#009E73) scatter points with the regression line in palette position 2 (#C475FD, lavender) — identical data colors across both themes.
  • Theme-adaptive chrome is fully threaded through: title, axis labels, ticks, grid, spines, legend frame, and the equation/R² annotation box all flip correctly between light and dark with no legibility issues.
  • Realistic, neutral educational dataset (study hours vs. exam scores) with sensible score clipping (20-100) producing a plausible R² = 0.848.

Weaknesses

  • Title omits the required language segment: currently "scatter-regression-linear · matplotlib · anyplot.ai" but the mandated format is "{spec-id} · {language} · {library} · anyplot.ai" — fix to "scatter-regression-linear · python · matplotlib · anyplot.ai".
  • Scatter marker size (s=100) sits at the floor of the recommended 100-200 range for this 80-point density; a few overlapping clusters (e.g. around x≈6.3-6.5, y≈70-75) blur into blobs — bump to ~120-140 for cleaner point separation.
  • Library Mastery is solid but not exceptional — beyond the rug-plot transform trick, the rest of the implementation (scatter, fill_between, polyfit) is fairly generic matplotlib/numpy usage; consider a distinctive touch such as ax.annotate with an arrow pointing at a notable outlier.

Issues Found

  1. SC-04 LOW: Title is missing the mandated "python" language segment
    • Fix: Change title = "scatter-regression-linear · matplotlib · anyplot.ai" to title = "scatter-regression-linear · python · matplotlib · anyplot.ai"
  2. VQ-03 MINOR: Marker size at the low end of the recommended range for this point density
    • Fix: Increase s=100 to s=120-140 in ax.scatter(...) for cleaner separation in the denser clusters

AI Feedback for Next Attempt

Fix the title format first — it must read "scatter-regression-linear · python · matplotlib · anyplot.ai" per the mandated {spec-id} · {language} · {library} · anyplot.ai pattern. Secondarily, bump scatter marker size slightly (s=120-140) to better separate the denser point clusters, and consider one more distinctive matplotlib touch (e.g. an annotated outlier) to strengthen Library Mastery and Data Storytelling.

Verdict: REJECTED

@github-actions github-actions Bot added quality:89 Quality score 89/100 ai-rejected Quality not OK, triggers update labels Aug 5, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

🔧 Repair Attempt 1/4

Applied fixes based on AI review feedback.

Status: Repair completed, re-triggering review...


🤖 impl-repair

@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): Warm off-white (#FAF8F1) background. Title "scatter-regression-linear · python · matplotlib · anyplot.ai" in dark ink, clearly readable and now correctly includes the "python" language segment. Axis labels "Study Hours (hrs)" / "Exam Score (points)" dark and legible; tick labels soft gray. Grid lines subtle on both axes. Brand-green scatter points (s=130, alpha ~0.7) with a lavender regression line and matching translucent CI band; a green rug plot along the bottom shows the marginal x-distribution. Equation/R² annotation box top-left, a new "Largest residual" callout with arrow pointing at the outlier near x≈3.7, and legend bottom-right — all readable, none overlapping data. All text is readable against the light background.

Dark render (plot-dark.png): Warm near-black (#1A1A17) background. Title, axis labels, and tick labels render in light ink — all clearly readable, no dark-on-dark failures anywhere (title, axes, ticks, legend, both annotation boxes all pass). The "Largest residual" arrow correctly flips to a light gray token for visibility. Data colors are identical to the light render: brand green scatter, lavender regression line and CI band, green rug ticks — confirming only chrome flipped.

Both renders pass the theme-readability check.

Score: 92/100

Category Score Max
Visual Quality 30 30
Design Excellence 14 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 8 10
Total 92 100

Visual Quality (30/30)

  • VQ-01: Text Legibility (8/8)
  • VQ-02: No Overlap (6/6)
  • VQ-03: Element Visibility (6/6) - marker size bumped to s=130, now well inside the 100-200 recommended range for n=80, cleaner separation in dense clusters
  • VQ-04: Color Accessibility (2/2)
  • VQ-05: Layout & Canvas (4/4)
  • VQ-06: Axis Labels & Title (2/2)
  • VQ-07: Palette Compliance (2/2)

Design Excellence (14/20)

  • DE-01: Aesthetic Sophistication (5/8) - Thoughtful secondary color, refined annotation callouts, theme-matched marker edges; above default but not publication-tier
  • DE-02: Visual Refinement (4/6) - Spines removed, subtle grid, generous whitespace; good but not flawless
  • DE-03: Data Storytelling (5/6) - Equation + R² box, CI shading, and the new "Largest residual" callout together create a clear, guided narrative

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5)
  • SC-02: Required Features (4/4)
  • SC-03: Data Mapping (3/3)
  • SC-04: Title & Legend (3/3) - Title now matches the mandated {spec-id} · python · matplotlib · anyplot.ai format

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6)
  • DQ-02: Realistic Context (5/5)
  • DQ-03: Appropriate Scale (4/4)

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3)
  • CQ-02: Reproducibility (2/2)
  • CQ-03: Clean Imports (2/2)
  • CQ-04: Code Elegance (2/2)
  • CQ-05: Output & API (1/1)

Library Mastery (8/10)

  • LM-01: Idiomatic Usage (5/5)
  • LM-02: Distinctive Features (3/5) - The blended-transform rug plot remains the standout distinctive technique; the rest (scatter, fill_between, polyfit, annotate) is fairly generic matplotlib/numpy usage

Score Caps Applied

  • None

Strengths

  • Title now matches the mandated format exactly: "scatter-regression-linear · python · matplotlib · anyplot.ai".
  • Scatter marker size bumped to s=130, comfortably inside the 100-200 recommended range for 80 points, giving cleaner separation in dense clusters.
  • New "Largest residual" callout with arrow annotation adds a genuine storytelling touch on top of the equation/R² box.
  • Rug plot along the bottom axis (via blended_transform_factory) remains a sophisticated, distinctive matplotlib transforms technique.
  • Confidence-interval band uses a correct t-distribution standard-error formula and renders as a clean, semi-transparent lavender fill that never obscures the underlying points.
  • Correct Imprint palette usage: brand green (#009E73) scatter points with the regression line/CI in palette position 2 (#C475FD, lavender) — identical data colors across both themes.
  • Theme-adaptive chrome fully threaded through: title, axis labels, ticks, grid, spines, legend frame, and both annotation boxes flip correctly between light and dark with no legibility issues.
  • Realistic, neutral educational dataset (study hours vs. exam scores) with sensible score clipping (20-100) producing a plausible R² = 0.848.

Weaknesses

  • Design Excellence is solid but still short of publication-tier: color/typography choices are thoughtful but not exceptional (DE-01), and refinement, while good, stops short of flawless (DE-02).
  • Library Mastery beyond the rug-plot transform trick is fairly generic matplotlib/numpy usage — a second genuinely library-distinctive technique would push LM-02 higher.

Issues Found

No blocking issues. Both items flagged in Attempt 1 (title format, marker size) are confirmed fixed.

AI Feedback for Next Attempt

N/A - approved.

Verdict: APPROVED

@github-actions github-actions Bot added quality:92 Quality score 92/100 ai-approved Quality OK, ready for merge and removed quality:89 Quality score 89/100 labels Aug 5, 2026
@MarkusNeusinger
MarkusNeusinger merged commit e37d1a7 into main Aug 5, 2026
3 checks passed
@MarkusNeusinger
MarkusNeusinger deleted the implementation/scatter-regression-linear/matplotlib branch August 5, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-approved Quality OK, ready for merge ai-attempt-1 First repair attempt quality:92 Quality score 92/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant