Skip to content

feat(letsplot): implement acf-pacf#8572

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Implementation: acf-pacf - python/letsplot

Implements the python/letsplot version of acf-pacf.

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

Parent Issue: #4663


🤖 impl-generate workflow

github-actions Bot added 2 commits June 10, 2026 01:52
Regen. Addressed:
- Canvas: ggsize(800,450) + scale=4 → exact 3200×1800 (was wrong ggbunch sizing)
- Theme-adaptive chrome: ANYPLOT_THEME-driven PAGE_BG/INK/INK_SOFT/GRID tokens
- Imprint palette: Significant=#009E73 (brand green), Non-significant=INK_MUTED
- Output: plot-{THEME}.png / plot-{THEME}.html with path="." fix
- Title: acf-pacf · python · letsplot · anyplot.ai (added language token, fixed domain)
- Import: explicit lets_plot symbols replacing wildcard+noqa pattern
- Layout: facet_wrap(ncol=1) replaces ggbunch for cleaner two-panel ACF/PACF
@claude

claude Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): Two-panel ACF/PACF stem plot on a warm off-white #FAF8F1 surface. Title "acf-pacf · python · letsplot · anyplot.ai" centered in dark ink, clearly readable. Axis label "Correlation" on the left, "Lag" on the bottom, both in dark ink. Tick labels in dark secondary gray (INK_SOFT). Bold facet strip labels "ACF" (top panel) and "PACF" (bottom panel) on slightly elevated strip backgrounds. Significant lags rendered as brand green (#009E73) vertical stems with circular endpoints; non-significant lags in muted gray. Dashed horizontal 95% CI lines at ±0.139. Zero baseline as solid line. Seasonal pattern at multiples of lag 12 clearly visible in ACF. Legend at bottom with styled box. All text readable against the light background.

Dark render (plot-dark.png): Same structure on warm near-black #1A1A17 surface. Title and all text adapt to light cream/gray chrome — no dark-on-dark failures. Facet strip labels "ACF" and "PACF" render in light text on dark elevated strip backgrounds (#242420). Legend text in light gray on dark elevated box. Data colors are identical to the light render: brand green significant stems, muted gray non-significant stems — only chrome flips. All text readable against the dark background.

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

Score: 86/100

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

Visual Quality (29/30)

  • VQ-01: Text Legibility (7/8) — All sizes explicitly set (title=16, axis=12, ticks=10, strip=12). Well-readable in both themes. Minor: strip labels at size=12 could be slightly larger for mobile readability.
  • VQ-02: No Overlap (6/6) — No text overlaps across 36+ lag stems in two panels.
  • VQ-03: Element Visibility (6/6) — Segment size=1.5 and point size=2.5 at scale=4 render clearly. Near-zero non-significant stems are intentionally small, correctly representing small correlations.
  • VQ-04: Color Accessibility (2/2) — Green vs muted gray is CVD-safe and luminance-distinct.
  • VQ-05: Layout & Canvas (4/4) — Two equal-height panels fill canvas well. Legend appropriately placed. No overflow or clipping.
  • VQ-06: Axis Labels & Title (2/2) — "Lag", "Correlation", facet labels "ACF"/"PACF", correct title format.
  • VQ-07: Palette Compliance (2/2) — First series #009E73, non-significant uses INK_MUTED (muted anchor — correct). Backgrounds #FAF8F1/#1A1A17. Chrome fully theme-adaptive in both renders.

Design Excellence (11/20)

  • DE-01: Aesthetic Sophistication (4/8) — Well-configured default. The significance color encoding is a thoughtful touch above minimum, but the overall design does not reach publication-level sophistication. No exceptional typography hierarchy, visual emphasis technique, or design elegance beyond clean defaults.
  • DE-02: Visual Refinement (3/6) — Subtle y-axis-only grid is good (x-axis grid removed, minor grid removed). However, all four panel borders remain visible (default lets-plot facet style) — style guide prefers L-shaped or open-panel spines. Whitespace is adequate but not generous.
  • DE-03: Data Storytelling (4/6) — The significant/non-significant color encoding actively guides the viewer to analytically important lags — genuine storytelling for ACF/PACF. The seasonal pattern at lag 12 emerges naturally. Good, though not exceptional (no annotation of the seasonal period or AR order identification).

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ACF/PACF stem plot with geom_segment + geom_point in two stacked facet panels.
  • SC-02: Required Features (4/4) — ACF top, PACF bottom, shared x-axis, stem lines from zero, 95% CI dashed lines, lag 0 in ACF, PACF from lag 1, 36 lags.
  • SC-03: Data Mapping (3/3) — X=lag, Y=correlation. ACF includes lag 0=1.0. PACF starts from lag 1.
  • SC-04: Title & Legend (3/3) — Title format correct. Legend "Significant" / "Non-significant" — descriptive and accurate.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Both ACF decay pattern and PACF cutoff visible. Significant and non-significant lags shown. Seasonal structure, trend, and noise all represented.
  • DQ-02: Realistic Context (5/5) — Monthly airline-style passenger series with trend and seasonality. Neutral, real-world domain.
  • DQ-03: Appropriate Scale (4/4) — 200 observations (spec recommends 100–500), 36 lags (spec recommends 30–40), seasonal period 12 appropriate for monthly data.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Clean Imports → Tokens → Data → Plot → Save. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set.
  • CQ-03: Clean Imports (2/2) — All imported symbols used (os, numpy, pandas, all lets_plot elements, statsmodels acf/pacf).
  • CQ-04: Code Elegance (2/2) — Clean, Pythonic, dataframe-based approach. Appropriate complexity.
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html with current API.

Library Mastery (6/10)

  • LM-01: Idiomatic Usage (4/5) — Expertly uses grammar-of-graphics: ggplot + geom_* + facet_wrap + scale_color_manual + theme(element_*) + ggsave. Idiomatic lets-plot approach.
  • LM-02: Distinctive Features (2/5) — HTML export and custom strip theming are somewhat distinctive, but the overall implementation pattern closely mirrors what ggplot2/plotnine would produce. No feature that is meaningfully unique to lets-plot's Python implementation.

Score Caps Applied

  • None

Strengths

  • Correct ACF/PACF stem plot with two stacked facet panels sharing the lag x-axis
  • Effective color encoding of significant vs non-significant lags using brand green and muted anchor — adds analytical storytelling without annotation
  • All five theme-adaptive chrome tokens correctly applied in both light and dark renders — no dark-on-dark failures
  • Seasonal pattern at lag 12 clearly visible in ACF panel, demonstrating a realistic airline-style time series
  • Perfect code structure: KISS, seed set, clean imports, correct plot-{THEME}.png + HTML output files

Weaknesses

  • All four panel borders are visible (default lets-plot facet style) — remove top and right panel borders for each facet panel to match the anyplot L-shaped spine convention
  • Strip text at size=12 is slightly small — increase to size=14 to make "ACF" / "PACF" panel headers more prominent at mobile scale
  • Design sophistication is at configured-default level — the significance color encoding is good but additional visual hierarchy (e.g., bolder stems for significant lags, or a subtle shaded confidence band) would elevate polish
  • Library mastery could be strengthened by using a feature more distinctive to lets-plot in Python (e.g., theme presets or a lets-plot-specific aesthetic)

Issues Found

  1. DE-02 LOW: All four panel borders visible in each facet — default lets-plot facet style keeps all four spines.
    • Fix: Add panel_border=element_blank() (or element_rect(color='transparent')) to remove top and right borders from facet panels, giving each panel an L-shaped frame
  2. DE-01 MEDIUM: Design lacks the sophistication to reach the ≥90 threshold on first attempt.
    • Fix: Add visual hierarchy — for example, make significant stems slightly thicker (size=2.0 vs 1.0 for non-significant), or add a semi-transparent confidence band (geom_ribbon from 0 to ±CI) in muted fill behind the stems; increase strip text to size=14
  3. LM-02 LOW: Implementation is functionally a ggplot2/plotnine equivalent with lets-plot syntax.
    • Fix: Leverage a lets-plot-specific feature, such as using theme_grey() as a base and selectively overriding, or using geom_livemap() / a built-in theme preset that differentiates the output

AI Feedback for Next Attempt

Remove top and right panel borders from each facet panel (panel_border=element_blank() or set to transparent). Increase strip text size from 12 to 14pt. Add visual hierarchy beyond color alone: differentiate significant vs non-significant stems by size (significant size=2.0 stems, non-significant size=0.8), making the important lags immediately prominent. Consider a subtle semi-transparent shaded band for the 95% CI region (geom_rect at full lag extent, ymin=-ci, ymax=ci, fill=GRID color, alpha=0.3) to make the confidence zone intuitive. These three changes would push DE-01 from 4 to 5–6 and DE-02 from 3 to 4–5, likely reaching ≥90.

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): Warm off-white (#FAF8F1) background — correct Imprint surface. Title "acf-pacf · python · letsplot · anyplot.ai" centered in dark ink, fills ~55% of plot width at appropriate size. Two stacked facet panels: ACF (top) and PACF (bottom) with bold "ACF"/"PACF" strip labels on slightly elevated backgrounds. Significant autocorrelation stems rendered in brand green (#009E73) with thick lines (size=2.0) and larger points (size=3.5); non-significant stems in muted gray with thinner lines and smaller points — strong visual hierarchy. 95% CI shown as dashed gray horizontal lines with a subtle shaded ribbon band. Lag 0 in ACF reaches 1.0 (gray by design since lag>0 significance check). Seasonal periodicity clearly visible in ACF at lags 12, 24, 36. PACF shows AR structure at lags 1–4. All text (title, axis labels, tick labels, legend, strip labels) is clearly readable against the light background.

Dark render (plot-dark.png): Warm near-black (#1A1A17) background — correct Imprint dark surface. Title and all text rendered in appropriate light tones (INK/INK_SOFT dark-theme tokens), clearly readable — no dark-on-dark failures. Facet strip labels bold and visible in light text on dark elevated strip (#242420). Data colors (green #009E73, muted gray) are identical to the light render — only chrome flips. CI dashed lines visible as lighter dashes. The CI ribbon (fill=INK_SOFT at alpha=0.1) is very faint in dark mode but marginally perceptible. Legend "Significant" (green) and "Non-significant" (gray) readable at bottom.

Both renders pass the theme-readability check. No dark-on-dark or light-on-light failures. Canvas gate: not triggered (ggsize(800,450) × scale=4 = 3200×1800 ✓).

Score: 89/100

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

Visual Quality (28/30)

  • VQ-01: Text Legibility (7/8) — Font sizes explicitly set (title=16, axis=12, tick=10). All text readable in both themes. Minor: CI ribbon nearly invisible in dark render.
  • VQ-02: No Overlap (6/6) — No overlapping text or data elements; 36 lags well-spaced.
  • VQ-03: Element Visibility (5/6) — Significant stems clearly visible; CI band fades in dark render at alpha=0.1.
  • VQ-04: Color Accessibility (2/2) — Imprint palette; green/gray is CVD-safe.
  • VQ-05: Layout & Canvas (4/4) — Correct 3200×1800. Two-panel layout well-proportioned. No overflow or clipping.
  • VQ-06: Axis Labels & Title (2/2) — Title correct format. Lag/Correlation descriptive. ACF/PACF panel labels prominent.
  • VQ-07: Palette Compliance (2/2) — First series #009E73. INK_MUTED for non-significant. Backgrounds #FAF8F1/#1A1A17. Both themes correct.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Intentional visual hierarchy: significant/non-significant differentiated by both color and size (thick green vs thin gray). Confidence band adds context. Above default (4) for deliberate design thinking.
  • DE-02: Visual Refinement (4/6) — theme_minimal() base. X-grid removed, y-grid only. Panel border removed. Elevated strip backgrounds with subtle border. Axis lines properly styled.
  • DE-03: Data Storytelling (4/6) — Color coding guides viewer immediately. Seasonal periodicity at lags 12, 24, 36 makes the pattern obvious. AR structure visible in PACF. No annotations to interpret patterns.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ACF/PACF stem plot using geom_segment + geom_point from zero baseline.
  • SC-02: Required Features (4/4) — ACF top, PACF bottom. Stems from zero. 95% CI dashed lines. Lag 0 in ACF. PACF from lag 1. 36 lags.
  • SC-03: Data Mapping (3/3) — X=lag, Y=correlation. All data within axis bounds.
  • SC-04: Title & Legend (3/3) — Title: "acf-pacf · python · letsplot · anyplot.ai". Legend: Significant/Non-significant.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Full ACF/PACF with seasonal patterns, CI, significance highlighting.
  • DQ-02: Realistic Context (5/5) — Airline-style monthly series with trend and seasonality; real-world plausible and neutral.
  • DQ-03: Appropriate Scale (4/4) — 200 observations, 36 lags, correlation in [-1, 1].

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — No functions or classes; clean flat structure.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42).
  • CQ-03: Clean Imports (2/2) — All imports used.
  • CQ-04: Code Elegance (2/2) — Clean separation of sig/nonsig dataframes; good use of geom_ribbon for CI.
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html.

Library Mastery (8/10)

  • LM-01: Idiomatic Usage (5/5) — facet_wrap for multi-panel, geom_segment+geom_point for lollipop stems, geom_ribbon for CI band, scale_color_manual, full theme customization. Very idiomatic grammar-of-graphics.
  • LM-02: Distinctive Features (3/5) — HTML export via ggsave is a distinctive lets-plot feature. Multi-layer composition with separate sig/nonsig datasets leveraged well. No use of lets-plot interactive features beyond HTML.

Score Caps Applied

  • None

Strengths

  • Excellent significant/non-significant visual hierarchy using both color (#009E73 vs INK_MUTED) and size (thick/thin stems, large/small points) — immediately guides the eye to significant autocorrelations
  • Full Imprint theme-adaptive chrome: all colors correctly flip between light and dark; no dark-on-dark or light-on-light failures
  • Correct faceted ACF/PACF layout: ACF includes lag 0, PACF starts from lag 1, 36 lags shown per spec
  • 95% CI shown via both dashed lines and geom_ribbon shaded band — dual encoding
  • Seasonal pattern clearly visible with periodic green spikes at lags 12, 24, 36
  • Idiomatic lets-plot grammar with comprehensive theme customization (x-grid removed, y-grid only, panel border removed, elevated strips)
  • Generates both PNG and HTML; seed-reproducible synthetic data with realistic airline-style seasonality

Weaknesses

  • Confidence band (geom_ribbon fill=INK_SOFT alpha=0.1) is nearly invisible in dark render — INK_SOFT is #B8B7B0 on #1A1A17 at 10% opacity fades almost completely; consider alpha=0.15–0.2 or a theme-adaptive fill with higher opacity in dark mode
  • Y-axis label is "Correlation" instead of per-panel "ACF"/"PACF" as specified — compensated by bold facet strip labels but technically diverges from spec wording

Issues Found

  1. DE-02 MINOR: CI ribbon visibility reduced in dark theme
    • Fix: Increase geom_ribbon alpha from 0.1 to ~0.18, or use a different fill token with better dark-mode contrast

AI Feedback for Next Attempt

Strong implementation with clear visual hierarchy and correct spec compliance. The main refinement is the CI ribbon visibility in dark mode — increase alpha slightly. Y-axis label could be changed to match spec ("ACF"/"PACF" per panel via facet) but this is minor since the facet strips already carry that information clearly.

Verdict: APPROVED

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant