Skip to content

feat(plotly): implement acf-pacf#8567

Merged
MarkusNeusinger merged 6 commits into
mainfrom
implementation/acf-pacf/plotly
Jun 10, 2026
Merged

feat(plotly): implement acf-pacf#8567
MarkusNeusinger merged 6 commits into
mainfrom
implementation/acf-pacf/plotly

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Implementation: acf-pacf - python/plotly

Implements the python/plotly version of acf-pacf.

File: plots/acf-pacf/implementations/python/plotly.py

Parent Issue: #4663


🤖 impl-generate workflow

github-actions Bot added 2 commits June 10, 2026 01:43
Regen from quality 90. Addressed:
- Canvas fixed: width=800, height=450, scale=4 → 3200×1800 (was 1600×900×3=4800×2700)
- Full theme-adaptive chrome: PAGE_BG, INK, INK_SOFT, INK_MUTED, GRID tokens
- Output renamed plot-{THEME}.png/.html (was bare plot.png/plot.html)
- Imprint palette: BRAND (#009E73) for significant lags, INK_MUTED for non-significant
- Title format fixed: added "python ·" language token, "anyplot.ai" domain
- Reduced 71 per-stem traces to 4 via None-separator technique (addresses CQ-04)
- Marker edges use PAGE_BG (not hardcoded white) for dark theme compatibility
@claude

claude Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): The plot renders on a warm off-white #FAF8F1 background. Two vertically stacked subplots share a common x-axis (lag number). The ACF subplot (top) shows vertical stem lines from zero to each correlation value, with the lag-0 autocorrelation at exactly 1.0 in brand green #009E73. Lags 1–2 are also green-significant with prominent markers (size=12). Non-significant lags use theme-adaptive gray (INK_MUTED). A subtle confidence band fill with dashed borders marks the ±1.96/√n bounds. The PACF subplot (bottom) shows a textbook AR(2) signature: significant spikes at lags 1 and 2, then a clean cutoff into the confidence band. Title ("Monthly Retail Sales · acf-pacf · python · plotly · anyplot.ai") and subtitle ("AR(2) Process (n=200, φ₁=0.7, φ₂=−0.3)") are clearly readable in dark ink. All axis labels and ticks are readable. One layout issue: the legend box (positioned at y=1.02, xanchor=right) overlaps with the Plotly-generated "Autocorrelation (ACF)" subplot title annotation — both occupy the same vertical band, with the "Autocorrelation" text partially behind the legend box. All text is otherwise readable against the light background. Legibility verdict: PASS with noted overlap.

Dark render (plot-dark.png): The plot renders on a warm near-black #1A1A17 background. The same two-subplot layout is used. Title and subtitle appear in light ink (#F0EFE8 / #B8B7B0), clearly readable against the dark surface. Axis labels, tick labels, and subplot annotations are all in appropriate light chrome tokens — no dark-on-dark failures. The zero baseline lines (in INK_SOFT = #B8B7B0) are visible as light horizontal rules. Data colors are identical to the light render: significant lags in brand green #009E73, non-significant in INK_MUTED #A8A79F. The Imprint palette invariant holds. The same legend/subplot-title overlap is present. No text is unreadable. Legibility verdict: PASS with noted overlap.

Both paragraphs are required. A review that only describes one render is invalid.

Score: 86/100

Category Score Max
Visual Quality 25 30
Design Excellence 12 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 9 10
Total 86 100

Visual Quality (25/30)

  • VQ-01: Text Legibility (7/8) — All font sizes explicitly set; adaptive title sizing applied; all text readable in both themes; minor visual tension near legend/subplot-title area
  • VQ-02: No Overlap (3/6) — Legend box at y=1.02, xanchor='right', x=1 overlaps the Plotly-generated "Autocorrelation (ACF)" subplot title annotation in both renders
  • VQ-03: Element Visibility (6/6) — Significant markers size=12, non-significant size=9; stem lines clearly visible; distinction is unambiguous
  • VQ-04: Color Accessibility (2/2) — Brand green vs INK_MUTED gray, good contrast, CVD-safe
  • VQ-05: Layout & Canvas (3/4) — Good proportions, shared x-axis works well; the legend/annotation overlap causes minor layout deduction
  • VQ-06: Axis Labels & Title (2/2) — "ACF (correlation)", "PACF (correlation)", "Lag (periods)" — descriptive
  • VQ-07: Palette Compliance (2/2) — Brand green #009E73 for significant lags; INK_MUTED for non-significant; backgrounds #FAF8F1/#1A1A17 correct; chrome fully theme-adaptive

Design Excellence (12/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above defaults: color-coded significance (green/gray), stem-dot approach, confidence band fill, hover tooltips with formatted lag/correlation, spike lines; intentional visual hierarchy
  • DE-02: Visual Refinement (3/6) — Y-only grid appropriate; spike lines add Plotly interactivity; legend placement causing overlap with subplot title annotation is a refinement failure
  • DE-03: Data Storytelling (4/6) — Green = significant creates clear visual hierarchy; PACF AR(2) cutoff at lag 2 is immediately readable; subtitle reveals the generating process for educational context

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — ACF and PACF as stem/scatter plots in correctly stacked subplots with shared x-axis
  • SC-02: Required Features (4/4) — Stem lines, markers, confidence bounds, shared x-axis, lag 0 in ACF only, PACF from lag 1, 35 lags, descriptive y-axis labels
  • SC-03: Data Mapping (3/3) — X=lag, Y=correlation; ACF top, PACF bottom; full lag range shown
  • SC-04: Title & Legend (3/3) — "Monthly Retail Sales · acf-pacf · python · plotly · anyplot.ai"; legend entries Significant/Non-significant/95% Confidence

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Both significant and non-significant lags shown; correct AR(2) PACF cutoff pattern; gradual ACF decay with oscillation
  • DQ-02: Realistic Context (5/5) — Monthly Retail Sales is a neutral, real-world, educationally rich time-series context
  • DQ-03: Appropriate Scale (4/4) — n=200 within spec (100–500); 35 lags within spec (30–40); AR coefficients (0.7, −0.3) produce realistic, instructive patterns

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Linear: imports → theme tokens → data → compute → plot → save; no functions/classes
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set
  • CQ-03: Clean Imports (2/2) — os, numpy, plotly.graph_objects, plotly.subplots.make_subplots — all used
  • CQ-04: Code Elegance (2/2) — None-separator trick for multi-segment stems is elegant; Durbin-Levinson PACF without statsmodels is appropriately complex
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html using current API

Library Mastery (9/10)

  • LM-01: Idiomatic Usage (5/5) — make_subplots(shared_xaxes=True), update_layout/update_xaxes/update_yaxes, per-trace hovertemplate — all idiomatic high-level Plotly patterns
  • LM-02: Distinctive Features (4/5) — Hover tooltips, spike lines (crosshair on hover), HTML export alongside PNG — distinctly Plotly features; not quite 5/5 since more creative Plotly-specific interactivity could be added

Score Caps Applied

  • None — VQ-02=3 (not 0), DE-01=5 (>2), no caps triggered

Strengths

  • Perfect spec compliance: ACF/PACF stacked subplots with shared x-axis, lag 0 in ACF only, PACF from lag 1, 35 lags, correct confidence bounds
  • Effective visual hierarchy: brand green #009E73 for significant lags vs. theme-adaptive gray — AR(2) PACF cutoff at lag 2 is immediately visible
  • Manual Durbin-Levinson PACF computation avoids external statsmodels dependency
  • Idiomatic Plotly: None-separator multi-segment stem lines, hovertemplate, spike lines, HTML export
  • Perfect data quality: Monthly Retail Sales AR(2) is neutral, realistic, educationally rich; subtitle exposes the generating process
  • Full theme-adaptive chrome in both renders with no dark-on-dark or light-on-light failures

Weaknesses

  • Legend overlaps the "Autocorrelation (ACF)" subplot title annotation in both renders — the legend at y=1.02, yanchor='bottom', xanchor='right', x=1 shares vertical space with the Plotly subplot annotation; fix by increasing top margin (e.g. t=160) to push the title higher, or relocate the legend (e.g. y=-0.15, yanchor='top' below the x-axis label, or y=0.98, x=0.98, yanchor='top' inside the top-right of the first subplot)
  • Design refinement penalty from the legend placement issue; once the overlap is resolved DE-02 can reach 4–5/6

Issues Found

  1. VQ-02 OVERLAP: Legend box and "Autocorrelation (ACF)" subplot title annotation overlap in both renders
    • Fix: Increase margin.t from 130 to at least 160, or move the legend to y=-0.15, yanchor='top', xanchor='center', x=0.5 (below x-axis label), or place it inside the first subplot at y=0.98, x=0.98, yanchor='top'
  2. DE-02 LOW (3/6): Legend placement refinement failure is the primary cause
    • Fix: Resolving the overlap above will also fix DE-02

AI Feedback for Next Attempt

Fix the legend/subplot-title overlap: increase margin.t to ~160 or reposition the legend below the plots (y=-0.15, yanchor='top', xanchor='center', x=0.5). This is the single change needed to clear the 90/100 threshold — everything else (spec compliance, data quality, code quality, library mastery) is perfect or near-perfect.

Verdict: REJECTED

@github-actions github-actions Bot added quality:86 Quality score 86/100 ai-rejected Quality not OK, triggers update labels Jun 10, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Jun 10, 2026
Attempt 1/3 - fixes based on AI review
@github-actions

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 Jun 10, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): Two vertically stacked subplots on a warm off-white #FAF8F1 background. The top panel shows the ACF and the bottom the PACF for a simulated AR(2) monthly retail sales time series. Significant lags (lag 0–2 in ACF, lag 1–2 in PACF) are rendered in brand green #009E73 as vertical stems (width=3) topped by circular markers (size=12) with white ring edges; non-significant lags use muted grey stems (width=2) and dots (size=9). A soft semi-transparent filled polygon with dashed borders marks the ±1.96/√n confidence band. A subtle INK_SOFT zero-baseline runs across each subplot. Subplot titles "Autocorrelation (ACF)" and "Partial Autocorrelation (PACF)" appear in muted text above each panel. Main title and subtitle are clearly centered. Legend at bottom identifies Significant / Non-significant / 95% Confidence. All text is clearly readable against the light background; no overflow or overlap detected.

Dark render (plot-dark.png): Same chart on a warm near-black #1A1A17 background. All chrome tokens correctly flip — title in #F0EFE8, axis labels and tick labels in #B8B7B0, legend box in #242420 with light border. Data colors are identical to the light render: significant lags remain #009E73 green, non-significant remain muted grey. The confidence band fill/border adapt via rgba opacity on the dark surface. No dark-on-dark failures — every text element is clearly legible against the near-black background; brand green #009E73 is fully visible. Legibility verdict: PASS for both renders.

Score: 91/100

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

Visual Quality (29/30)

  • VQ-01: Text Legibility (7/8) — All sizes explicitly set (title adaptive 16px, subplot annotations 13px, axis labels 12px, ticks 10px, legend 10px); both themes fully readable. Minor: subplot annotation font (13px) is only 1px above axis labels (12px) — weak panel hierarchy contrast.
  • VQ-02: No Overlap (6/6) — No text overlaps in either render; stems, markers, and legend well-separated.
  • VQ-03: Element Visibility (6/6) — Significant markers size=12 with white edge and stems width=3 excellent; non-significant size=9/width=2 appropriately secondary. Confidence band visible in both themes.
  • VQ-04: Color Accessibility (2/2) — Green vs muted grey is CVD-safe; not a red-green pair; white marker edges add definition.
  • VQ-05: Layout & Canvas (4/4) — 3200×1800 confirmed. Margins l=90/r=50/t=130/b=100 balanced. Two subplots with 10% vertical spacing, legend well-placed below.
  • VQ-06: Axis Labels & Title (2/2) — "ACF (correlation)", "PACF (correlation)", "Lag (periods)" — all descriptive with units.
  • VQ-07: Palette Compliance (2/2) — Significant lags use #009E73 (Imprint Add workflow diagram for new prototype discovery #1). Non-significant uses INK_MUTED semantic anchor (theme-adaptive). Background #FAF8F1/#1A1A17 correct. Data colors identical across themes.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above defaults: intentional significant/non-significant hierarchy, white marker edges, soft confidence band fills, adaptive subtitle. template='plotly_white' base leaves top/right axis lines visible — explicit spine cleanup would add polish.
  • DE-02: Visual Refinement (4/6) — Y-grid only at 15% opacity, legend with ELEVATED_BG, subplot titles in muted tone. Top/right bounding lines from plotly_white default not removed — full L-shaped or frameless treatment would reach 6/6.
  • DE-03: Data Storytelling (4/6) — Green vs grey visual hierarchy creates immediate focal points. AR(2) story is visually unmistakable: ACF decays slowly, PACF cuts off at lag 2. Subtitle communicates the process parameters. Viewer reads the ARIMA order at a glance.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ACF/PACF stem plot, two stacked subplots with shared x-axis, vertical stems from zero (not filled bars).
  • SC-02: Required Features (4/4) — ACF top/PACF bottom ✓, stems from zero ✓, 95% CI ✓, lag 0 in ACF ✓, PACF from lag 1 ✓, 35 lags ✓, axis labels ✓.
  • SC-03: Data Mapping (3/3) — X-axis lags 0–35, Y-axes correlation −1 to 1, shared_xaxes=True.
  • SC-04: Title & Legend (3/3) — "Monthly Retail Sales · acf-pacf · python · plotly · anyplot.ai" matches {Descriptive} · {spec-id} · {lang} · {lib} · anyplot.ai. Legend: Significant / Non-significant / 95% Confidence.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — ACF decay pattern, PACF cutoff at lag 2, significant/non-significant distinction, confidence band, lag-0 = 1.0. All ACF/PACF diagnostic features present.
  • DQ-02: Realistic Context (5/5) — Monthly retail sales is neutral and comprehensible. AR(2) with φ₁=0.7, φ₂=−0.3 is a realistic stationary time series. Subtitle explains the generative process.
  • DQ-03: Appropriate Scale (4/4) — n=200 (within 100–500 range), 35 lags (within 30–40), CI bound ≈ 0.139 (mathematically correct), AR(2) coefficients are stationary.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Clean linear flow: imports → tokens → data → ACF/PACF computation → stem coords → traces → layout → save. No functions/classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) present.
  • CQ-03: Clean Imports (2/2) — All 4 imports (os, numpy, plotly.graph_objects, plotly.subplots) used; no extras.
  • CQ-04: Code Elegance (2/2) — None-separator multi-segment line pattern, Durbin-Levinson inline, length-adaptive title formula, conditional trace addition. Appropriate complexity.
  • CQ-05: Output & API (1/1) — plot-{THEME}.png + plot-{THEME}.html, autosize=False, correct 800×450×4 scale.

Library Mastery (9/10)

  • LM-01: Idiomatic Usage (5/5) — make_subplots(shared_xaxes=True), fill='toself' confidence polygon, None-separator stems, hovertemplate with <extra></extra>, update_xaxes/yaxes per row, spike lines.
  • LM-02: Distinctive Features (4/5) — Hover tooltips, HTML export, showspikes=True/spikemode='across' for cross-subplot lag tracking. Minor gap: both subplots fire independent hovers — a unified hover aggregating ACF+PACF values at the same lag (via customdata + shared hoverinfo) would be the distinctive Plotly showcase.

Score Caps Applied

  • None — no caps triggered.

Strengths

  • Excellent significant/non-significant visual encoding: green stems+markers vs muted grey creates immediate visual hierarchy that directs the viewer to meaningful lags
  • Perfect spec compliance: every required ACF/PACF feature present and correct
  • Full theme adaptation: all chrome tokens flip correctly between light and dark; no dark-on-dark failures
  • Self-contained PACF via Durbin-Levinson recursion — no external statsmodels dependency
  • Clean KISS code with seed, no unused imports, length-adaptive title

Weaknesses

  • Top/right axis lines from template='plotly_white' not explicitly removed — L-shaped or frameless cleanup would improve aesthetic sophistication (DE-01/DE-02)
  • Subplot annotation font (13px) barely distinguishable from axis labels (12px) — bump to 14px for clearer panel title hierarchy (VQ-01)
  • Spike lines fire independently per subplot; a unified hover aggregating both ACF and PACF values at the same lag would demonstrate deeper Plotly mastery (LM-02)

Issues Found

  1. DE-02 PARTIAL: Top/right bounding lines visible from plotly_white default
    • Fix: add fig.update_xaxes(showline=False, row=1) for top edge and equivalent for right edges of both subplots, or switch to a template that removes all bounding boxes and rely only on the explicit showline=True on the bottom/left axes
  2. VQ-01 minor: Subplot annotation font (13px) too close to axis label font (12px)
    • Fix: set annotation font to 14px in the for annotation in fig.layout.annotations loop

AI Feedback for Next Attempt

This is a strong implementation that passes at attempt 2 (91/100 ≥ 80 threshold). If a future repair is needed: (1) remove the top/right axis bounding lines explicitly — fig.update_xaxes(showline=False) globally then re-enable only row=2 bottom; (2) bump subplot annotation font to 14px; (3) consider a unified hover tooltip that shows both ACF and PACF values at the same lag via customdata + shared hovertemplate to maximize LM-02.

Verdict: APPROVED

@github-actions github-actions Bot added quality:91 Quality score 91/100 ai-approved Quality OK, ready for merge and removed quality:86 Quality score 86/100 labels Jun 10, 2026
@MarkusNeusinger MarkusNeusinger merged commit cd52b76 into main Jun 10, 2026
3 checks passed
@MarkusNeusinger MarkusNeusinger deleted the implementation/acf-pacf/plotly branch June 10, 2026 02:02
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:91 Quality score 91/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant