Skip to content

feat(plotnine): implement line-retention-cohort#4932

Merged
github-actions[bot] merged 6 commits intomainfrom
implementation/line-retention-cohort/plotnine
Mar 16, 2026
Merged

feat(plotnine): implement line-retention-cohort#4932
github-actions[bot] merged 6 commits intomainfrom
implementation/line-retention-cohort/plotnine

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: line-retention-cohort - plotnine

Implements the plotnine version of line-retention-cohort.

File: plots/line-retention-cohort/implementations/plotnine.py

Parent Issue: #4572


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 16, 2026

AI Review - Attempt 1/3

Image Description

The plot displays 5 retention curves for monthly signup cohorts (Jan–May 2025) over 12 weeks. Lines transition from light, transparent blue-gray (Jan 2025, oldest) to bold orange-red (May 2025, newest), creating a visual hierarchy emphasizing recent cohorts. All curves start at 100% at week 0 and decay exponentially, with newer cohorts retaining better. A dashed gray horizontal line marks the 20% retention threshold, with a small "20% threshold" annotation near the right end. The Y-axis shows "Retained Users" with percentage labels (0%–100%), X-axis shows "Weeks Since Signup" (0–12). Points mark each data value on the lines. A legend on the right lists each cohort with sample size (e.g., "Jan 2025 (n=1,245)"). The title reads "line-retention-cohort · plotnine · pyplots.ai" in bold. Background is clean white with subtle horizontal gridlines.

Score: 86/100

Category Score Max
Visual Quality 28 30
Design Excellence 13 20
Spec Compliance 15 15
Data Quality 14 15
Code Quality 10 10
Library Mastery 6 10
Total 86 100

Visual Quality (28/30)

  • VQ-01: Text Legibility (7/8) - All font sizes explicitly set (title 24, axis 20, ticks 16, legend title 18, legend 14). The "20% threshold" annotation at size=9 is small relative to other text.
  • VQ-02: No Overlap (6/6) - No overlapping text or elements. Legend well-separated from data area.
  • VQ-03: Element Visibility (5/6) - Lines visible at size=1.5 with points at 2.5. Oldest cohort (Jan) at alpha=0.45 is somewhat faint, especially near lower values.
  • VQ-04: Color Accessibility (4/4) - Blue-to-orange palette is colorblind-safe with good contrast between cohorts.
  • VQ-05: Layout & Canvas (4/4) - 16:9 ratio, plot fills canvas well, legend positioned cleanly on the right.
  • VQ-06: Axis Labels & Title (2/2) - "Weeks Since Signup" and "Retained Users" are descriptive. Y-axis tick labels show percentage units.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) - Custom blue-to-orange palette with intentional cool-to-warm progression. Alpha gradient adds emphasis. Above configured defaults but not quite publication-quality.
  • DE-02: Visual Refinement (4/6) - Minimal theme, removed minor grid and x-major grid. Subtle y-grid with alpha=0.5. Axis lines added. Good refinement visible.
  • DE-03: Data Storytelling (4/6) - Alpha and color progression guide the eye to the newest cohort. 20% threshold provides benchmark context. Clear narrative of improving retention over time.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) - Correct line chart with multiple cohort curves.
  • SC-02: Required Features (4/4) - All spec features present: starts at 100%, distinct colors, legend with cohort label and size, y-axis 0–100% with gridlines, x-axis as time since signup, decreasing opacity for older cohorts, dashed 20% reference line.
  • SC-03: Data Mapping (3/3) - X = weeks since signup, Y = retention rate. All data visible across full range.
  • SC-04: Title & Legend (3/3) - Title format "line-retention-cohort · plotnine · pyplots.ai" correct. Legend labels match spec format "Jan 2025 (n=1,245)".

Data Quality (14/15)

  • DQ-01: Feature Coverage (5/6) - 5 cohorts across 13 time periods. Shows exponential decay with different rates demonstrating improving retention. Good variety but all curves follow similar shape.
  • DQ-02: Realistic Context (5/5) - Monthly signup cohorts with realistic sizes (1,100–1,455). Neutral product analytics context.
  • DQ-03: Appropriate Scale (4/4) - Sensible retention values for a SaaS product. Decay rates and cohort sizes are plausible.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) - Flat script: imports → data → plot → save. No functions or classes.
  • CQ-02: Reproducibility (2/2) - np.random.seed(42) set.
  • CQ-03: Clean Imports (2/2) - All imports used.
  • CQ-04: Code Elegance (2/2) - Clean, appropriate complexity. No fake UI or over-engineering.
  • CQ-05: Output & API (1/1) - Saves as plot.png with current plotnine API.

Library Mastery (6/10)

  • LM-01: Idiomatic Usage (4/5) - Good grammar of graphics usage with proper aes mappings, geom layers, scales, and theme customization. pd.Categorical for ordering and scale_alpha_identity are idiomatic patterns.
  • LM-02: Distinctive Features (2/5) - Uses layer composition and scale_alpha_identity which are ggplot-style patterns, but doesn't leverage deeply distinctive plotnine features (e.g., stat layers, after_stat, position adjustments, or coord transforms).

Score Caps Applied

  • None

Strengths

  • Full spec compliance — every required feature from the specification is implemented correctly
  • Thoughtful blue-to-orange color progression with alpha gradient creates effective temporal hierarchy
  • Clean, well-structured code following KISS principles with proper reproducibility
  • Realistic product analytics data with appropriate cohort sizes and decay patterns

Weaknesses

  • Oldest cohorts (Jan, Feb) at alpha 0.45–0.55 are somewhat faint, reducing readability
  • "20% threshold" annotation is small (size=9) compared to other text elements
  • Design could be more polished — title weight, annotation styling, and overall hierarchy could be elevated
  • Library mastery stays at basic grammar-of-graphics level without leveraging distinctive plotnine capabilities

Issues Found

  1. DE-01 MODERATE: Design is above defaults but lacks the final polish for publication quality
    • Fix: Consider more intentional typography hierarchy, potentially a subtitle or caption for context
  2. LM-02 LOW: Generic ggplot usage without distinctive plotnine features
    • Fix: Consider using plotnine-specific features like annotate("segment") for the threshold, or leveraging after_stat() for computed aesthetics
  3. VQ-03 MINOR: Oldest cohort faintness at alpha=0.45
    • Fix: Raise minimum alpha to ~0.55 so all cohorts remain clearly visible

AI Feedback for Next Attempt

To reach 90+: (1) Raise minimum alpha from 0.45 to ~0.55 so oldest cohorts remain clearly readable. (2) Increase the "20% threshold" annotation size to match the overall text scale. (3) Elevate design polish — consider adding a subtitle with context (e.g., "Monthly signup cohorts, 12-week tracking"), refine the color palette further, and explore more intentional visual hierarchy. (4) Leverage distinctive plotnine features beyond basic grammar of graphics — consider annotate with segment/rect for threshold region, or use stat-based transformations.

Verdict: REJECTED

@github-actions github-actions bot added quality:86 Quality score 86/100 ai-rejected Quality not OK, triggers update labels Mar 16, 2026
@github-actions github-actions bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Mar 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

🔧 Repair Attempt 1/3

Applied fixes based on AI review feedback.

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


🤖 impl-repair

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 16, 2026

AI Review - Attempt 2/3

Image Description

The plot displays 5 user retention curves for monthly signup cohorts (Jan–May 2025), each starting at 100% and decaying over 12 weeks. Colors progress from light steel blue (oldest cohort, Jan) through medium blue (Mar) to dark burnt orange/red (newest, May). Lines use graduated alpha (0.6–1.0) and thickness (1.0–2.0pt) to visually emphasize recent cohorts. A subtle blue-shaded ribbon spans the area between the oldest and newest cohort curves, labeled "Improvement gap" in a boxed annotation. A horizontal dashed gray line marks the 20% retention threshold with an italic annotation. Endpoint percentage labels appear at week 12 for each cohort (17%, 19%, 34%, 40%, 57%). The legend on the right shows cohort labels with sample sizes (e.g., "Jan 2025 (n=1,245)") inside a light gray box with border. Title reads "line-retention-cohort · plotnine · pyplots.ai" in bold. Y-axis labeled "Retained Users" with percentage gridlines; X-axis labeled "Weeks Since Signup" with integer ticks 0–12.

Score: 91/100

Category Score Max
Visual Quality 26 30
Design Excellence 16 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 9 10
Total 91 100

Visual Quality (26/30)

  • VQ-01: Text Legibility (8/8) — All font sizes explicitly set: title=24, axis_title=20, axis_text=16, legend_title=18, legend_text=14. All perfectly readable.
  • VQ-02: No Overlap (4/6) — The endpoint labels "19%" and "17%" for the two oldest cohorts overlap slightly at week 12. Minor but visible.
  • VQ-03: Element Visibility (6/6) — Lines and points well-sized with graduated thickness and alpha. Data points clearly visible at all positions.
  • VQ-04: Color Accessibility (3/4) — Blue-to-orange progression is generally colorblind-safe, but the three blue shades (Jan, Feb, Mar) may be hard to distinguish for some viewers.
  • VQ-05: Layout & Canvas (3/4) — Good overall layout with 16:9 aspect ratio. Slight crowding on right side where endpoint labels meet the legend.
  • VQ-06: Axis Labels & Title (2/2) — "Weeks Since Signup" and "Retained Users" are descriptive and contextual.

Design Excellence (16/20)

  • DE-01: Aesthetic Sophistication (6/8) — Custom blue-to-orange palette with intentional color progression, refined typography with color hierarchy (#1a1a1a title, feat(plotnine): implement scatter-basic #444 labels, feat(plotly): implement donut-labeled #555 ticks), graduated alpha/size for temporal emphasis. Clearly above defaults.
  • DE-02: Visual Refinement (5/6) — X-grid removed, Y-grid subtle (#EBEBEB, 0.4pt, alpha=0.6), axis lines present but thin, legend styled with background and border, generous whitespace via plot_margin. Well-polished.
  • DE-03: Data Storytelling (5/6) — "Improvement gap" ribbon highlights the spread between oldest and newest cohorts, endpoint % labels quantify final retention, 20% threshold line provides benchmark context, alpha/size graduation directs attention to recent (better-performing) cohorts. Clear narrative: retention is improving over time.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct line chart with multiple cohort curves showing retention decay.
  • SC-02: Required Features (4/4) — All curves start at 100%; distinct colors per cohort; legend with cohort label and size; Y-axis 0–100% with gridlines; X-axis as time since signup; dashed 20% reference line; opacity/thickness variation for emphasis.
  • SC-03: Data Mapping (3/3) — X=weeks since signup, Y=retention percentage, correctly mapped.
  • SC-04: Title & Legend (3/3) — Title follows exact format "line-retention-cohort · plotnine · pyplots.ai". Legend labels show "Jan 2025 (n=1,245)" format matching spec.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Shows 5 cohorts with different decay rates and plateau levels, clear progression from poor to strong retention, variation in cohort sizes.
  • DQ-02: Realistic Context (5/5) — Real-world product analytics scenario with monthly signup cohorts, plausible user counts (1,102–1,455), exponential decay with noise.
  • DQ-03: Appropriate Scale (4/4) — Retention values follow realistic exponential decay curves with sensible plateau levels (8%–30%). Cohort sizes in thousands are typical for SaaS products.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Clean imports → data generation → plot construction → save flow. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set before data generation.
  • CQ-03: Clean Imports (2/2) — All imports are used: geom_ribbon, geom_text, annotate, scale_alpha_identity, scale_size_identity, guide_legend, element_blank/line/rect/text all utilized.
  • CQ-04: Code Elegance (2/2) — Well-organized with clear sections, appropriate complexity for the visualization. No over-engineering.
  • CQ-05: Output & API (1/1) — Saves as plot.png with dpi=300. Current plotnine API.

Library Mastery (9/10)

  • LM-01: Idiomatic Usage (5/5) — Expert use of plotnine's grammar of graphics: ggplot + aes + layered geoms, scale_identity for data-mapped aesthetics, guide_legend with override_aes, comprehensive theme customization via element functions.
  • LM-02: Distinctive Features (4/5) — Uses scale_alpha_identity and scale_size_identity with data-column mapping (a distinctive ggplot2/plotnine pattern), annotate("label") for boxed text annotations, geom_ribbon for shaded regions, and guide_legend override_aes for legend customization.

Score Caps Applied

  • None applied

Strengths

  • Excellent data storytelling with the "Improvement gap" ribbon, endpoint labels, and 20% threshold annotation
  • Graduated alpha and line width effectively emphasize recent cohorts
  • Custom color palette with intentional blue-to-orange progression
  • All spec requirements fully implemented including cohort sizes in legend
  • Expert use of plotnine's grammar of graphics with identity scales

Weaknesses

  • Minor overlap of endpoint labels (17% and 19%) for the two oldest cohorts at week 12
  • Three blue shades for Jan/Feb/Mar cohorts could be more distinct

Issues Found

  1. VQ-02 MINOR: Endpoint labels "19%" and "17%" overlap slightly at week 12
    • Fix: Adjust nudge_y for these labels or use different vertical offsets

AI Feedback for Next Attempt

Strong implementation with excellent storytelling and design. Minor endpoint label overlap at week 12 is the only notable issue but does not significantly impact readability.

Verdict: APPROVED

@github-actions github-actions bot added quality:91 Quality score 91/100 ai-approved Quality OK, ready for merge labels Mar 16, 2026
@github-actions github-actions bot merged commit 5fa0310 into main Mar 16, 2026
@github-actions github-actions bot deleted the implementation/line-retention-cohort/plotnine branch March 16, 2026 20:58
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:86 Quality score 86/100 quality:91 Quality score 91/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants