Skip to content

feat(plotnine): implement acf-pacf#8573

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Implementation: acf-pacf - python/plotnine

Implements the python/plotnine version of acf-pacf.

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

Parent Issue: #4663


🤖 impl-generate workflow

github-actions Bot and others added 2 commits June 10, 2026 01:54
Regen from quality 90. Addressed:
- Canvas: fixed figure_size=(16,10)/dpi=300 → (8,4.5)/dpi=400 for canonical 3200×1800
- Theme: added ANYPLOT_THEME support with full theme-adaptive chrome (PAGE_BG, INK, INK_SOFT, INK_MUTED)
- Colors: replaced custom hexes (Python Blue/muted silver/red) with Imprint palette (BRAND=#009E73 for significant, ALARM=#AE3030 for CI bounds, INK_MUTED for non-significant)
- Y-axis label: removed shared "Correlation" label; ACF/PACF strip headers now serve as per-panel identifiers per spec
- Title: fixed to include language token — "acf-pacf · python · plotnine · anyplot.ai"
- Output: fixed save to f"plot-{THEME}.png" with dpi=400
- Added sys.path workaround for script/library name conflict
- Reduced y-axis expansion from default 5% to 4% to reduce PACF empty space

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude

claude Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): Warm off-white #FAF8F1 background — correct anyplot light surface. Title "acf-pacf · python · plotnine · anyplot.ai" in dark ink at top — clearly readable. Strip labels "ACF" (top panel) and "PACF" (bottom panel) in bold dark ink — clearly readable. X-axis label "Lag" and tick labels (0, 6, 12…36; correlation values) in INK_SOFT gray — readable. Two-panel layout: ACF top, PACF bottom. Significant lags in brand green #009E73, non-significant in muted gray. Lag 0 in ACF rendered gray by design (always 1.0, excluded from significance coding). Dashed red #AE3030 confidence bounds at ±0.127. Strong periodic spikes at lags 6, 12, 18, 24, 30, 36 in ACF (seasonal period-12/6 structure). PACF shows early significant green spikes (lags 1, 5–7) reflecting AR structure. All text readable against light background.

Dark render (plot-dark.png): Warm near-black #1A1A17 background — correct anyplot dark surface. Title in light #F0EFE8 — clearly readable against dark background. Strip labels "ACF" / "PACF" in bold light ink — readable. X-axis label "Lag" and tick labels in #B8B7B0 secondary ink — readable. No dark-on-dark failures detected anywhere. Data colors identical to light render — significant lags in #009E73 green, non-significant in adaptive muted gray. Confidence bounds remain #AE3030 dashed red. Strong green/dark contrast is excellent for dark mode.

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

Score: 89/100

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

Visual Quality (30/30)

  • VQ-01: Text Legibility (8/8) — All sizes explicitly set (title=12, axis=10, tick=8, strip=10); readable in both themes
  • VQ-02: No Overlap (6/6) — No overlapping elements
  • VQ-03: Element Visibility (6/6) — Segments size=1.2, points size=3.0 well-adapted to 37-lag density
  • VQ-04: Color Accessibility (2/2) — Green vs muted gray: good contrast, CVD-safe
  • VQ-05: Layout & Canvas (4/4) — Two panels fill 3200×1800 canvas proportionally
  • VQ-06: Axis Labels & Title (2/2) — "Lag" x-axis; "ACF"/"PACF" effectively labeled via strip labels
  • VQ-07: Palette Compliance (2/2) — #009E73 first series, muted gray non-significant, #AE3030 semantic threshold, correct backgrounds both themes

Design Excellence (12/20)

  • DE-01: Aesthetic Sophistication (4/8) — Well above defaults due to semantic color encoding for significance; lacks publication-ready polish (title regular weight, typographic hierarchy could be stronger)
  • DE-02: Visual Refinement (4/6) — Good: Y-only grid at 12% alpha, zero baseline, clean strip labels. Strip background (elevated BG) creates minor visual discontinuity vs panel background
  • DE-03: Data Storytelling (4/6) — Good visual hierarchy via significance coloring; seasonal period-12 and AR(1) structure visible but without intentional emphasis on key structural features

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ACF/PACF lollipop/stem plots in stacked subplots
  • SC-02: Required Features (4/4) — All features: stem lines, 95% CI dashed bounds, lag 0 in ACF, PACF from lag 1, 36 lags, shared x-axis range
  • SC-03: Data Mapping (3/3) — X=lag, Y=correlation; all data visible
  • SC-04: Title & Legend (3/3) — Correct title format; legend suppressed, strip labels identify panels

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Significant and non-significant lags, lag 0=1.0, seasonal spikes, AR structure in PACF
  • DQ-02: Realistic Context (5/5) — Monthly temperature with seasonality and AR(1) — realistic, neutral, plausible
  • DQ-03: Appropriate Scale (4/4) — Correlation values in [-1,1], realistic seasonal amplitude and noise

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Flat: imports → data → compute → df → plot → save
  • CQ-02: Reproducibility (2/2) — np.random.seed(42)
  • CQ-03: Clean Imports (2/2) — All imports used; sys/os justified by naming conflict workaround
  • CQ-04: Code Elegance (2/2) — Clean, no fake functionality, appropriate complexity
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png at 3200×1800 correct

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) — Very idiomatic: facet_wrap with ordered pd.Categorical, layer composition, guides(color="none"), scale_x_continuous with breaks
  • LM-02: Distinctive Features (3/5) — Ordered categorical for panel ordering is plotnine-specific; grammar-of-graphics layer composition for lollipop stems is distinctly ggplot-style

Score Caps Applied

  • None

Strengths

  • Perfect Visual Quality: all font sizes explicitly set, clean layout, readable in both themes
  • Semantic color encoding — brand green for significant lags, muted gray for non-significant — creates instant visual hierarchy and matches plot purpose
  • Full Imprint palette compliance with correctly theme-adaptive chrome across both light and dark renders
  • All spec-required features implemented: stem lines, 95% CI bounds, lag 0 in ACF, PACF from lag 1, 36 lags, both panels
  • Realistic monthly temperature data with genuine seasonal (period-12/6 spikes in ACF) and AR(1) (early PACF decay) structure

Weaknesses

  • DE-01: Title uses regular weight — add plot_title=element_text(face='bold') to strengthen typographic hierarchy between title, strip labels, and tick labels
  • DE-02: strip_background=ELEVATED_BG creates a subtle visual discontinuity; consider reducing panel_spacing_y from 0.2 to ~0.1 for a more cohesive two-panel layout
  • DE-03: The seasonal period-12 pattern (major spikes at lags 12, 24, 36 in ACF) is the key structural feature — consider stronger visual emphasis on those lags (e.g., slightly larger points at those positions or a subtle vertical annotation line)

Issues Found

  1. DE-01 LOW (4/8): Design is above defaults but lacks publication-ready polish
    • Fix: plot_title=element_text(color=INK, size=12, face='bold') for stronger title; consider slight increase in plot_margin for breathing room
  2. DE-02 MODERATE (4/6): Strip background creates subtle visual discontinuity; inter-panel spacing feels slightly generous
    • Fix: Reduce panel_spacing_y=0.2 to panel_spacing_y=0.1; optionally set strip_background=element_rect(fill=PAGE_BG) with a separator line
  3. DE-03 MODERATE (4/6): Significance coloring provides hierarchy but seasonal structure could be more intentionally emphasized
    • Fix: Consider slightly larger point size (3.5) for significant lags vs 2.5 for non-significant, or add a subtle geom_vline at the seasonal period lags (12, 24, 36)

AI Feedback for Next Attempt

Score: 89/100 — strong implementation with perfect Visual Quality, Spec Compliance, Data Quality, and Code Quality. To reach 90+, focus on Design Excellence (12/20). Three targeted fixes: (1) bold title weight face='bold' for clearer typographic hierarchy, (2) reduce panel_spacing_y from 0.2 to 0.1 for a tighter two-panel layout, (3) stronger emphasis on seasonal-period lags in ACF (lags 12, 24, 36) via slightly larger significant-lag point size or a redundant encoding. These are small changes that would push DE-01 to 5-6 and DE-02 to 5.

Verdict: REJECTED

@github-actions github-actions Bot added quality:89 Quality score 89/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): The plot shows two stacked lollipop/stem panels on a warm off-white (#FAF8F1) background. The top panel (ACF) displays autocorrelation values for lags 0–36, with lag 0 anchored at 1.0. Significant lags (those outside the dashed confidence bounds) are colored brand green (#009E73), while non-significant lags are rendered in muted gray (#6B6A63). Red (#AE3030) dashed horizontal lines mark the ±95% confidence interval. Subtle vertical dotted green lines at lags 12, 24, and 36 indicate the seasonal period. The bottom panel (PACF) applies the same styling from lag 1 onwards, showing a clear AR(1) structure (lag 1 significant, rest mostly within bounds). The title "acf-pacf · python · plotnine · anyplot.ai" spans approximately 55% of width in bold dark text. Strip labels "ACF" and "PACF" are bold and visible. X-axis ticks (0, 6, 12, 18, 24, 30, 36) and the "Lag" x-axis label are clear. All text is readable against the light background. Legibility verdict: PASS.

Dark render (plot-dark.png): Same plot on a warm near-black (#1A1A17) background. Background is clearly dark, not pure black. Title and strip labels are rendered in light cream (#F0EFE8), axis labels and tick labels in light gray (#B8B7B0) — all clearly readable against the dark surface. Data colors are identical to the light render: significant lags in #009E73, non-significant in muted gray, confidence bounds in red dashes. The brand green seasonal markers at lags 12, 24, 36 are equally subtle at alpha=0.14. No dark-on-dark failures detected — all chrome elements correctly adapt to the dark surface. Legibility verdict: PASS.

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

Score: 91/100

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

Visual Quality (30/30)

  • VQ-01: Text Legibility (8/8) — All font sizes explicitly set (title=12, axis_title_x=10, strip_text=10, axis_text=8); well-proportioned in both themes; title spans ~55% of width at 41 chars
  • VQ-02: No Overlap (6/6) — No overlapping text or data elements; facet spacing clean
  • VQ-03: Element Visibility (6/6) — Lollipop stems (size=1.2) and points (size=3.0) well-adapted to 36-lag density; confidence bounds clearly distinguishable
  • VQ-04: Color Accessibility (2/2) — Two distinct hues (green vs muted gray) with adequate luminance separation; CVD-safe via Imprint palette
  • VQ-05: Layout & Canvas (4/4) — Two-panel layout fills canvas well; balanced margins; 3200×1800 confirmed; no clipping
  • VQ-06: Axis Labels & Title (2/2) — X-axis "Lag" present; "ACF"/"PACF" strip labels per spec convention; correct title format
  • VQ-07: Palette Compliance (2/2) — Significant lags use first Imprint position #009E73; confidence bounds use semantic red #AE3030; backgrounds #FAF8F1/#1A1A17 correct; all chrome theme-adaptive in both renders

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above the well-configured-default baseline: intentional semantic color coding (green=significant, muted=not), semantic red for threshold lines, and seasonal period markers as contextual cues reflect deliberate design thinking beyond defaults
  • DE-02: Visual Refinement (4/6) — X-axis grid removed (clean for stem plots), Y-axis grid subtle (size=0.2, alpha=0.12), strip background matches panel, tight panel spacing (0.08), legend hidden — genuine refinement above library defaults
  • DE-03: Data Storytelling (4/6) — Clear narrative: seasonal autocorrelation at lags 12/24/36 (highlighted by vertical dotted markers) and AR(1) structure visible in PACF at lag 1; significance coloring creates immediate visual hierarchy guiding the viewer to the meaningful lags

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ACF+PACF stem/lollipop plot in two vertically stacked subplots with shared x-axis
  • SC-02: Required Features (4/4) — Vertical stem lines from zero baseline ✓; 95% CI dashed lines ✓; lag 0 in ACF only ✓; PACF starts from lag 1 ✓; 36 lags (within 30–40 range) ✓
  • SC-03: Data Mapping (3/3) — X=lag number, Y=correlation; all lags visible; both panels share x-axis via facet_wrap
  • SC-04: Title & Legend (3/3) — Title "acf-pacf · python · plotnine · anyplot.ai" ✓; legend hidden (appropriate — no separate legend needed for a two-panel diagnostic plot)

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Demonstrates all key ACF/PACF features: lag-0 anchor at 1.0, seasonal spikes at multiples of 12, AR(1) decay in PACF, mixture of significant and non-significant lags
  • DQ-02: Realistic Context (5/5) — Monthly temperature time series with annual seasonality and AR(1) component — realistic, neutral, domain-appropriate scenario with 240 observations (20 years)
  • DQ-03: Appropriate Scale (4/4) — Correlation values bounded [-1, 1]; confidence bounds at ±1.96/sqrt(240) ≈ ±0.126 are physically correct; seasonal period-12 structure realistic for monthly climate data

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Linear flow: imports → tokens → data generation → ACF/PACF computation → DataFrame assembly → plot definition → save; no functions/classes
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set before all stochastic operations
  • CQ-03: Clean Imports (2/2) — All imported names are used; statsmodels.tsa.stattools acf/pacf used; os/sys used for path workaround
  • CQ-04: Code Elegance (2/2) — Clean Pythonic code; sys.path workaround is documented with a comment explaining the naming-conflict reason; no fake UI
  • CQ-05: Output & API (1/1) — Saves as plot-{THEME}.png with correct dpi/width/height parameters

Library Mastery (8/10)

  • LM-01: Idiomatic Usage (5/5) — Expertly uses plotnine's grammar: facet_wrap with scales="free_y", pd.Categorical for ordered panel control, geom_segment+geom_point layering for lollipops, guides(color="none"), data= parameter in geom_vline for panel-specific annotations — full exploitation of plotnine's ggplot2 grammar
  • LM-02: Distinctive Features (3/5) — Uses plotnine-specific patterns: free-scale faceting (scales="free_y"), ordered pd.Categorical for panel ordering, and panel-specific data injection via geom_vline(data=seasonal_ann_df) — moderately distinctive, though the core approach would transfer to ggplot2

Score Caps Applied

  • None — all category conditions for caps evaluated and none triggered

Strengths

  • Full visual quality with all font sizes explicitly set and both themes rendering cleanly — no dark-on-dark failures
  • Semantic color coding distinguishes significant from non-significant lags immediately, creating a clear visual hierarchy without a legend
  • Seasonal period markers (vertical dotted lines at lags 12, 24, 36) enrich the ACF panel with interpretive context beyond what the spec requires
  • Perfect spec compliance: lag 0 in ACF only, PACF from lag 1, 95% CI dashed lines, 36 lags, shared x-axis via faceting
  • Idiomatic plotnine usage: facet_wrap with free_y scales, pd.Categorical for panel ordering, panel-specific geom_vline with data= parameter

Weaknesses

  • DE-01 ceiling at 5/8: the design is intentional and above defaults but lacks the visual polish that would push it to "strong design" — e.g., no custom typography weight hierarchy beyond bold strip labels, no subtle annotation note about what the seasonal markers represent
  • LM-02 at 3/5: the panel-specific geom_vline technique is distinctive, but the overall approach remains close to what ggplot2 would produce; more plotnine-idiomatic fine-tuning (e.g., explicit theme element_line for axis spines) could differentiate it further

Issues Found

None requiring repair — no spec violations, no visual defects, no threshold failures.

AI Feedback for Next Attempt

This implementation meets the ≥80 threshold for Attempt 2. Approved as-is. If a future repair attempt were needed, focus would be on: (1) adding a subtle footnote or strip sub-label explaining the seasonal marker significance; (2) increasing DE-01 through more deliberate typography hierarchy (e.g., different weight for the "ACF"/"PACF" strip vs tick labels).

Verdict: APPROVED

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