Skip to content

feat(pygal): implement acf-pacf#8569

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Implementation: acf-pacf - python/pygal

Implements the python/pygal version of acf-pacf.

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

Parent Issue: #4663


🤖 impl-generate workflow

github-actions Bot added 2 commits June 10, 2026 01:49
Regen from quality 85. Addressed:
- Canvas fixed to 3200×1800 (was 4800×2700)
- Added ANYPLOT_THEME support for light/dark rendering
- Replaced non-Imprint colors with Imprint palette (#009E73 for significant bars, INK_MUTED for non-significant, ANYPLOT_AMBER for CI lines)
- Fixed output filenames to plot-{THEME}.png / plot-{THEME}.html
- Fixed background to Imprint page surfaces (#FAF8F1 light / #1A1A17 dark)
- Updated font sizes to style-guide values (title=66, label=56, major_label=44)
- Added sys.path fix to prevent self-import when script name matches package name
@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 background (#FAF8F1). Title "acf-pacf · python · pygal · anyplot.ai" in dark ink, clearly readable. Two-panel layout: ACF (top) and PACF (bottom) stacked vertically. Significant bars rendered in #009E73 (brand green), non-significant bars in muted grey. Dashed amber (#DDCC77) CI lines at ±0.139 visible in both panels. Zero baseline in muted grey. Seasonal pattern clearly visible at lags 12, 24, 36 in ACF. "95% CI: ±0.139" amber annotation in upper-right margin. Key issue: Y-axis tick labels in both panels are extremely densely packed — approximately 17 decimal values stacked in a small vertical space, visibly overlapping. The y_labels_major_count=4 setting did not suppress minor labels effectively. X-axis labels, axis titles, and title are all readable. Legibility: PARTIAL FAIL on Y-axis tick labels.

Dark render (plot-dark.png): Warm near-black background (#1A1A17). Title and all chrome rendered in light cream/white text — clearly readable against the dark surface. No dark-on-dark failures: all text (title, "ACF", "PACF", "Lag", X-axis ticks) is light-colored and readable. Data colors are identical to the light render — green #009E73 bars, grey non-significant bars, amber CI lines. The same Y-axis tick label overlap issue is present as in the light render, but text appears in light color. Legibility: PARTIAL FAIL on Y-axis tick labels (same density/overlap issue), no other theme-adaptation failures.

Both renders share the same core visual issue: Y-axis tick labels in both panels are too densely stacked and overlapping. All other text elements pass readability in both themes.

Score: 76/100

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

Visual Quality (24/30)

  • VQ-01: Text Legibility (5/8) — Font sizes explicitly set; title and axis titles readable; Y-axis tick labels densely overlapping in both panels
  • VQ-02: No Overlap (3/6) — Y-axis tick labels overlap each other; data elements are fine
  • VQ-03: Element Visibility (6/6) — Bars well-sized; significant/non-significant distinction clear
  • VQ-04: Color Accessibility (2/2) — Colorblind-safe; green vs grey uses luminance difference
  • VQ-05: Layout & Canvas (4/4) — Two-panel layout fills canvas well; balanced margins
  • VQ-06: Axis Labels & Title (2/2) — X: "Lag", Y: "ACF" / "PACF"; title correct
  • VQ-07: Palette Compliance (2/2) — First series #009E73; amber CI lines; correct backgrounds both themes; data colors identical across themes

Design Excellence (10/20)

  • DE-01: Aesthetic Sophistication (4/8) — Well-configured but not exceptional; rounded bars add subtle polish; default pygal look overall
  • DE-02: Visual Refinement (2/6) — Default grid shows guides for every tick; minimal refinement beyond theme colors
  • DE-03: Data Storytelling (4/6) — Significant/non-significant color coding creates clear visual hierarchy; seasonal pattern at lags 12, 24, 36 immediately visible

Spec Compliance (14/15)

  • SC-01: Plot Type (5/5) — Correct two-panel ACF/PACF; spec description allows "bar plots"
  • SC-02: Required Features (3/4) — All features present; minor deduction because spec notes say "not filled bars" and pygal has no stem chart type
  • SC-03: Data Mapping (3/3) — Correct lag → X, correlation → Y; ACF includes lag 0; PACF starts lag 1
  • SC-04: Title & Legend (3/3) — "acf-pacf · python · pygal · anyplot.ai" correct format; no legend (single-series per panel — appropriate)

Data Quality (13/15)

  • DQ-01: Feature Coverage (5/6) — Shows positive/negative correlations, seasonal spikes, slow decay; PACF cut-off pattern
  • DQ-02: Realistic Context (4/5) — Synthetic airline-style passenger data; plausible and neutral
  • DQ-03: Appropriate Scale (4/4) — ACF range −0.5 to 1.0; 36 lags within spec recommendation

Code Quality (9/10)

  • CQ-01: KISS Structure (2/3) — Two helper functions (hex_to_rgb, _inject_ci_lines) necessary for pygal's SVG API limitation but technically violate no-functions rule
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) present
  • CQ-03: Clean Imports (2/2) — All imports used
  • CQ-04: Code Elegance (2/2) — SVG injection creative and appropriate; no fake functionality
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png + plot-{THEME}.html; current API

Library Mastery (6/10)

  • LM-01: Idiomatic Usage (3/5) — Style object used correctly; many pygal config options; CI lines require SVG workarounds showing library limitation
  • LM-02: Distinctive Features (3/5) — SVG injection leverages pygal's rendering pipeline; interactive dual-panel HTML export is distinctive

Score Caps Applied

  • None

Strengths

  • Correct Imprint palette: significant bars in #009E73, non-significant in INK_MUTED, CI lines in ANYPLOT_AMBER — semantic color roles applied correctly
  • Theme-adaptive chrome works correctly in both renders: warm off-white background in light, near-black in dark, all text readable in both
  • SVG injection technique for CI dashed lines and zero baseline is creative and works around pygal's lack of native reference-line API
  • 36-lag ACF/PACF with synthetic airline-style data clearly shows seasonal pattern at multiples of lag 12 — data story is visible
  • Interactive HTML export correctly leverages pygal's distinctive interactive SVG feature

Weaknesses

  • Y-axis tick labels are densely packed and overlapping in both ACF and PACF panels — the y_labels_major_count=4 setting does not appear to be suppressing minor labels; fix by explicitly setting y_labels to 4–5 key values (e.g., acf_chart.y_labels = ['-0.4', '-0.2', '0.0', '0.5', '1.0']) instead of relying on the count setting
  • The spec explicitly states "Use vertical stem lines (not filled bars)" — while pygal has no native stem chart type, narrower bars would better approximate the stem appearance
  • DE-02 refinement is minimal: the default pygal Y-axis horizontal grid guides are shown for every minor label which creates a busy grid; limit to 4–5 major Y guides to reduce visual noise
  • CQ-01 KISS violation: two helper functions defined (hex_to_rgb, _inject_ci_lines) — _inject_ci_lines is necessary but adds structural complexity

Issues Found

  1. VQ-01/VQ-02 MEDIUM: Y-axis tick labels overflow and overlap in both panels
    • Fix: Explicitly set y_labels on each chart to only 4–5 key values spanning the Y range, e.g. acf_chart.y_labels = ['-0.5', '-0.2', '0.0', '0.5', '1.0']. Do not rely on y_labels_major_count alone.
  2. DE-02 LOW: Default busy grid with horizontal guides for every tick
    • Fix: Use the explicit y_labels fix above (fewer labels → fewer guide lines automatically) or disable minor guides via show_minor_y_labels=False

AI Feedback for Next Attempt

Fix the Y-axis tick label overflow first — explicitly set y_labels to 4–5 values per panel (e.g., ['-0.5', '-0.2', '0.0', '0.5', '1.0']) rather than relying on y_labels_major_count. This will also clean up the grid, solving DE-02 simultaneously. For DE-01, consider tightening bar_spacing slightly to make bars thinner/more stem-like to better match the spec. The palette and theme-adaptive chrome are correct — preserve them.

Verdict: REJECTED

@github-actions github-actions Bot added quality:76 Quality score 76/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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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-panel stacked layout on a warm off-white background (~#FAF8F1). The ACF panel (top) shows 37 lags (0–36) with vertical filled bars colored brand green (#009E73) for significant correlations and muted gray for non-significant ones. A clear seasonal pattern is visible with spikes at multiples of 12. The PACF panel (bottom) shows lags 1–36 with a sharp spike at lag 1 and rapid decay — characteristic AR behavior. Both panels share amber dashed lines (#DDCC77) at the ±95% CI bounds, with a "95% CI: ±0.139" annotation in the upper-right corner. Y-axis labels "ACF" / "PACF" are on the left; "Lag" appears below the PACF panel. Title "acf-pacf · python · pygal · anyplot.ai" sits atop the ACF panel. All text is clearly readable against the light background — no legibility issues.

Dark render (plot-dark.png): Same two-panel layout on a warm near-black background (~#1A1A17). Title, axis labels ("ACF", "PACF", "Lag"), and tick labels all render in light cream text — clearly readable against the dark surface with no dark-on-dark failures. Data bar colors are identical to the light render: brand green for significant bars, muted gray for non-significant ones. The amber CI dashed lines and corner annotation remain visible. The zero baseline line is subtly present. Both panels theme-correct. No legibility issues in dark mode.

Both paragraphs required. Both renders reviewed and confirmed readable.

Score: 85/100

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

Visual Quality (28/30)

  • VQ-01: Text Legibility (7/8) — All text readable in both themes; font sizes appropriate (title 66, labels 56, ticks 44). Minor: y-axis ticks at -0.4, -0.2, 0, 0.5, 1.0 are non-uniform spacing (0→0.5 gap larger than -0.4→-0.2), which could subtly confuse scale interpretation.
  • VQ-02: No Overlap (5/6) — No text overlaps with data or other text; tightly packed bars in ACF lags 4–8 are visually dense but no actual collision.
  • VQ-03: Element Visibility (6/6) — Significant bars (green) and non-significant bars (gray) are clearly distinguishable; CI amber dashed lines and zero baseline are visible in both renders.
  • VQ-04: Color Accessibility (2/2) — Brand green / muted gray / amber amber are distinct under CVD simulations; no red-green signal ambiguity.
  • VQ-05: Layout & Canvas (4/4) — Canvas gate passed (3200×1800 confirmed); two-panel composition clean; no overflow or clipping detected in either render.
  • VQ-06: Axis Labels & Title (2/2) — Y-axes labeled "ACF"/"PACF", x-axis "Lag". Title matches required format exactly.
  • VQ-07: Palette Compliance (2/2) — Significant bars use #009E73 (first series ✓); non-significant use INK_MUTED (semantic muted anchor ✓); CI lines use #DDCC77 (amber warning anchor ✓); backgrounds #FAF8F1 / #1A1A17 correct for both themes.

Design Excellence (12/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above default: semantic color split (significant=green, non-significant=gray) shows design intent; amber CI lines add a purposeful warning-channel element; CI annotation in upper corner adds information density without clutter; rounded bar corners add softness. Not quite publication-ready polish.
  • DE-02: Visual Refinement (3/6) — Y-axis-only grid (no x-axis guides); pygal's minimal default chrome (no top/right spines); subtle panel divider line. Missing: explicit spine-removal treatment; whitespace between panels could be tighter.
  • DE-03: Data Storytelling (4/6) — The green/gray semantic coloring immediately directs the eye to significant lags; seasonal 12-period pattern in ACF and AR cutoff in PACF are visually prominent. Clear focal point through color alone — effective.

Spec Compliance (14/15)

  • SC-01: Plot Type (4/5) — Correct ACF/PACF dual-panel concept; however, spec explicitly requires "vertical stem lines (not filled bars)" — pygal.Bar produces filled bars. This is a pygal API limitation (no native stem type), but the deviation from spec is real.
  • SC-02: Required Features (4/4) — ACF top / PACF bottom ✓; 95% CI dashed lines ✓; lag 0 in ACF ✓; PACF from lag 1 ✓; 36 lags (within 30–40 range) ✓.
  • SC-03: Data Mapping (3/3) — X-axis lag numbers correct for both panels; Y-axis correlation values correctly mapped; all lags shown.
  • SC-04: Title & Legend (3/3) — Title "acf-pacf · python · pygal · anyplot.ai" matches required format; legend omitted (show_legend=False) — appropriate for semantically-colored single-series.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Both ACF and PACF shown; confidence intervals; significant-vs-not coloring; zero baseline; 37 and 36 lags respectively.
  • DQ-02: Realistic Context (5/5) — Monthly airline-style passenger data with trend + 12-period seasonality; neutral domain; 200 observations; ACF seasonal pattern and PACF AR cutoff are statistically plausible.
  • DQ-03: Appropriate Scale (4/4) — Y-range [-0.5, 1.1] for ACF, [-0.5, 1.0] for PACF — covers all values; 36 lags is appropriate for n=200.

Code Quality (9/10)

  • CQ-01: KISS Structure (2/3) — Two helper functions present: hex_to_rgb (small utility) and _inject_ci_lines (complex SVG injection). The SVG injection helper is justified by pygal's lack of a native reference-line API, but the overall structure is slightly beyond flat.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) ✓.
  • CQ-03: Clean Imports (2/2) — All imports used; no dead imports.
  • CQ-04: Code Elegance (2/2) — Good use of shared config dict for common_config; per-bar color via pygal dict syntax is clean; sys.path manipulation is a necessary workaround (documented inline).
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html ✓.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) — Good use of pygal Style object for full theming; per-bar color dict ({"value": v, "color": color}) is pygal's idiomatic way to vary bar colors; x_labels_major_every for tick control; render() for SVG bytes. The sys.path workaround is necessary.
  • LM-02: Distinctive Features (3/5) — Per-bar color variation via dict syntax is a distinctive pygal feature; HTML output via pygal's interactive SVG rendering; SVG namespace manipulation via ElementTree for custom CI line injection demonstrates advanced library knowledge.

Score Caps Applied

  • None — no caps triggered.

Strengths

  • Semantic color coding (significant=green, non-significant=gray) provides immediate interpretive value without a legend
  • ANYPLOT_AMBER (#DDCC77) used correctly as a warning/caution anchor for CI threshold lines
  • Both renders fully theme-adaptive: backgrounds, text, gridlines all correctly flip between light and dark
  • SVG injection technique for CI lines is elegant workaround for pygal's missing reference-line API
  • Data (airline-style seasonal series) produces textbook ACF/PACF patterns that showcase the plot type well
  • Clean composition: common_config dict reduces repetition; per-bar color dict is idiomatic pygal

Weaknesses

  • Filled bars (pygal.Bar) instead of vertical stem lines as specified — spec explicitly requests "vertical stem lines (not filled bars)". Consider using very narrow bar widths or XY scatter with vertical line segments via SVG injection to better approximate stems
  • Non-uniform y-axis tick spacing (-0.4, -0.2, 0, 0.5, 1.0) — the 0→0.5 gap is 2.5× the -0.2→0 gap, which can mislead scale perception; prefer uniform ticks like [-0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0] or at minimum [-0.5, 0.0, 0.5, 1.0]
  • _inject_ci_lines helper function deviates from the KISS structure ideal — acceptable but noted
  • Visual refinement could be stronger: panel spacing between ACF and PACF could be tighter (the gap looks generous), and whitespace utilization inside each panel could be improved

Issues Found

  1. SC-01 MINOR: Filled bars instead of stem lines — spec says "vertical stem lines (not filled bars)"
    • Fix: Use very narrow bar widths or inject thin vertical line segments via SVG manipulation to better approximate stem plots
  2. VQ-01 MINOR: Non-uniform y-axis tick spacing creates subtle scale distortion
    • Fix: Use uniform tick intervals, e.g. y_labels = [-0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0]

AI Feedback for Next Attempt

This is a strong implementation — score 85. If rejected/repaired: (1) Use narrower bar widths or SVG-injected vertical line segments to better approximate stem lines per spec. (2) Use uniform y-axis tick spacing. (3) These are the only meaningful gaps; the theming, data, and library usage are well-executed.

Verdict: APPROVED

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant