Skip to content

update(density-basic): altair — comprehensive quality review#4384

Merged
github-actions[bot] merged 5 commits intomainfrom
implementation/density-basic/altair
Feb 23, 2026
Merged

update(density-basic): altair — comprehensive quality review#4384
github-actions[bot] merged 5 commits intomainfrom
implementation/density-basic/altair

Conversation

@MarkusNeusinger
Copy link
Copy Markdown
Owner

Summary

Updated altair implementation for density-basic.

Changes: Comprehensive quality review

Changes

  • Added rug plot layer with mark_tick showing individual observations
  • Tighter x-domain for better canvas utilization
  • Refined grid to dashed lines at 20% opacity
  • Quality: 90/100 (local self-evaluation, after 2 iterations)

Test Plan

  • Preview images uploaded to GCS staging
  • Implementation file passes ruff format/check
  • Metadata YAML updated with current versions
  • Automated review triggered

Generated with Claude Code /update command

Comprehensive quality review: added rug plot layer, tighter domain, dashed grid.
Copilot AI review requested due to automatic review settings February 23, 2026 22:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the altair implementation of the density-basic plot with a comprehensive quality review. The main changes include adding a rug plot layer to show individual observations, refining the x-domain for better canvas utilization, and updating grid styling.

Changes:

  • Added rug plot layer using mark_tick to display individual data points along the x-axis
  • Refined x-domain from auto to fixed [10, 100] for tighter visualization
  • Updated grid styling to dashed lines with 20% opacity
  • Modified data generation to clip values within realistic test score range
  • Updated metadata with current Python version (3.14.3) and set quality_score to null

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
plots/density-basic/implementations/altair.py Updated implementation with rug plot, tighter domain, refined styling; header shows incomplete quality score
plots/density-basic/metadata/altair.yaml Updated metadata with new Python version, timestamp, and null quality_score

preview_thumb: https://storage.googleapis.com/pyplots-images/plots/density-basic/altair/plot_thumb.png
preview_html: https://storage.googleapis.com/pyplots-images/plots/density-basic/altair/plot.html
quality_score: 92
quality_score: null
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quality_score field is set to null, which is inconsistent with the PR description claiming "Quality: 90/100 (local self-evaluation, after 2 iterations)". This should either contain the quality score value or be omitted entirely if not yet evaluated.

Suggested change
quality_score: null
quality_score: 90

Copilot uses AI. Check for mistakes.
Library: altair 6.0.0 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-23
Library: altair 6.0.0 | Python 3.14
Quality: /100 | Updated: 2026-02-23
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quality score in the header is incomplete, showing "Quality: /100" instead of a specific score. Based on the PR description mentioning "Quality: 90/100 (local self-evaluation, after 2 iterations)", this should be updated to "Quality: 90/100" or the actual final score once automated review is completed.

Suggested change
Quality: /100 | Updated: 2026-02-23
Quality: 90/100 | Updated: 2026-02-23

Copilot uses AI. Check for mistakes.
density-basic: Basic Density Plot
Library: altair 6.0.0 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-23
Library: altair 6.0.0 | Python 3.14
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python version in the header shows "Python 3.14" but should match the more specific version "Python 3.14.3" from the metadata file for consistency. All other implementations in the codebase follow the pattern of "Python X.Y" (e.g., "Python 3.14") without the patch version, but the metadata shows "3.14.3". Either update the header to "Python 3.14.3" to match metadata, or update metadata to "3.14" to match the header convention.

Suggested change
Library: altair 6.0.0 | Python 3.14
Library: altair 6.0.0 | Python 3.14.3

Copilot uses AI. Check for mistakes.
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 23, 2026

AI Review - Attempt 1/3

Image Description

The plot displays a kernel density estimation (KDE) curve for test scores, rendered as a filled area chart in muted blue (#306998) with a darker blue outline (#1e4d6e). The curve shows a clear bimodal distribution with two peaks — a taller peak around score 38 (reaching density ~0.030) and a shorter peak around score 72 (reaching density ~0.019). A rug plot of small vertical tick marks in blue sits along the bottom of the chart, showing individual data point concentrations that visually reinforce the two clusters. The x-axis is labeled "Test Score (points)" spanning 10–100, and the y-axis is labeled "Probability Density" spanning 0.000–0.034. The title reads "density-basic · altair · pyplots.ai" in large font at the top. Grid lines are subtle dashed lines at low opacity. The view frame border has been removed.

Score: 87/100

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

Visual Quality (27/30)

  • VQ-01: Text Legibility (7/8) — All font sizes explicitly set (title 28pt, axis titles 22pt, tick labels 18pt); all readable at full resolution. Minor: y-axis density labels are verbose with many decimals.
  • VQ-02: No Overlap (6/6) — No overlapping text or data elements anywhere in the plot.
  • VQ-03: Element Visibility (5/6) — Density curve is clearly visible with good fill opacity. Rug plot ticks overlap in dense clusters (around scores 30–45), making individual ticks hard to distinguish.
  • VQ-04: Color Accessibility (4/4) — Single-series Python Blue; no colorblind issues. Good contrast between fill and outline.
  • VQ-05: Layout & Canvas (3/4) — Decent canvas utilization but x-axis domain extends from 10–100 while actual data starts around 20, creating wasted space on the left. Plot fills ~55% of canvas.
  • VQ-06: Axis Labels & Title (2/2) — "Test Score (points)" includes units; "Probability Density" is descriptive and standard.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above defaults: intentional Python Blue color scheme with darker outline, custom fill opacity. Not yet publication-quality — single-tone palette, could benefit from more distinctive visual identity.
  • DE-02: Visual Refinement (4/6) — Good refinement: subtle dashed grid (opacity 0.2), view frame removed (strokeWidth=0), domain color softened to gray. Could improve further by removing horizontal grid lines or using y-only grid for a density plot.
  • DE-03: Data Storytelling (4/6) — Bimodal distribution creates natural visual interest with two clear focal points. Rug plot reinforces the density concentrations. The data choice itself tells a story (two student groups), though no annotations explain the peaks.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct KDE/density plot using Altair's transform_density.
  • SC-02: Required Features (4/4) — Smooth density curve ✓, filled area with transparency ✓, rug plot ✓, appropriate bandwidth (4) ✓.
  • SC-03: Data Mapping (3/3) — X maps to continuous variable (Test Score), Y maps to probability density. All data visible.
  • SC-04: Title & Legend (3/3) — Title follows exact format "density-basic · altair · pyplots.ai". Single series — no legend needed, correctly omitted.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Bimodal distribution demonstrates KDE's ability to reveal complex distribution shapes. Asymmetric peaks (different heights/widths) add visual richness. Excellent showcase of density estimation.
  • DQ-02: Realistic Context (5/5) — "Test scores" for two student course groups is a neutral, educational, real-world scenario.
  • DQ-03: Appropriate Scale (4/4) — Scores clipped to 5–100, means at 38 and 72, standard deviations of 7–8 — all realistic for test score distributions.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Clean Imports → Data → Density → Rug → Combine → Save structure with no functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) ensures reproducible output.
  • CQ-03: Clean Imports (2/2) — All three imports (altair, numpy, pandas) are used.
  • CQ-04: Code Elegance (2/2) — Clean, well-organized with method chaining. Minor note: alt.value(880) for rug y-position is a hardcoded pixel value, but overall code is elegant.
  • CQ-05: Output & API (1/1) — Saves as plot.png with scale_factor=3.0 and interactive HTML. Current Altair API.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) — Good use of Altair idioms: declarative encoding, transform_density, alt.layer for composition, .properties/.configure chains. Minor: alt.value(880) for rug positioning is fragile (depends on chart height pixel value).
  • LM-02: Distinctive Features (3/5) — Uses Altair-specific transform_density (KDE computed in Vega-Lite transform pipeline), mark_tick() for rug plot, and interactive HTML export with tooltips. Could leverage more distinctive features like selections or conditional encodings.

Score Caps Applied

  • None — no cap conditions triggered.

Strengths

  • Bimodal data choice effectively demonstrates KDE capabilities with a clear, real-world educational scenario
  • Rug plot adds valuable context showing individual data point concentrations
  • Clean, well-structured code following Altair idioms with declarative transform_density
  • All font sizes explicitly set ensuring readability at 4800×2700 resolution
  • Subtle grid styling and removed view frame show intentional design refinement

Weaknesses

  • Rug plot uses hardcoded pixel position alt.value(880) — fragile if chart dimensions change
  • X-axis domain (10–100) extends beyond data range (~20–95), wasting left-side canvas space
  • Single-tone blue palette lacks the visual distinctiveness needed for publication quality
  • No visual emphasis or annotation distinguishing the two distribution modes

Issues Found

  1. DE-01 at 5/8: Good design above defaults but not yet publication-quality
    • Fix: Consider a more distinctive color approach — e.g., gradient fill, or a complementary accent for the outline. Explore more refined typography choices.
  2. VQ-05 at 3/4: X-axis domain extends beyond actual data range
    • Fix: Tighten x-axis domain to better fit data (e.g., 15–100 instead of 10–100) to reduce wasted space.
  3. LM-01 at 4/5: Rug plot y-positioning uses hardcoded pixel value
    • Fix: Use a more robust positioning approach for the rug plot that doesn't depend on exact chart pixel height.
  4. LM-02 at 3/5: Could leverage more Altair-distinctive features
    • Fix: Consider adding Altair-specific features like selection parameters or conditional encoding to showcase library mastery.

AI Feedback for Next Attempt

Score is 87 — close to approval. To reach 90+: (1) Improve design sophistication by using a more refined fill approach (e.g., gradient or layered density effect) and tighten the x-axis domain to eliminate wasted space. (2) Fix the rug plot y-positioning to avoid hardcoded pixel values. (3) Leverage more Altair-distinctive features like selection-based interactivity or conditional encodings. (4) Consider adding subtle visual cues (e.g., text annotations or contrasting peak highlights) to strengthen the bimodal data storytelling.

Verdict: REJECTED

@github-actions github-actions Bot added quality:87 Quality score 87/100 ai-rejected Quality not OK, triggers update labels Feb 23, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Feb 23, 2026
Attempt 1/3 - fixes based on AI review
Copilot AI review requested due to automatic review settings February 23, 2026 22:55
@MarkusNeusinger MarkusNeusinger review requested due to automatic review settings February 23, 2026 22:55
@github-actions
Copy link
Copy Markdown
Contributor

🔧 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 Feb 23, 2026

AI Review - Attempt 2/3

Image Description

The plot displays a kernel density estimation (KDE) curve of test scores rendered as a filled area in muted blue (#306998) with a darker blue outline (#1e4d6e, strokeWidth 2.5). The distribution is clearly bimodal with two peaks: a taller peak around score 38 (reaching density ~0.030) labeled "Foundational Course" in bold dark blue text above it, and a shorter peak around score 72 (reaching density ~0.019) labeled "Advanced Course." A rug plot of thin blue tick marks sits along the baseline (y=0) showing individual data point concentrations, visibly denser around the two peaks. The x-axis is labeled "Test Score (points)" spanning roughly 10–100, the y-axis "Probability Density" spanning 0.000–0.034 with 3-decimal formatting. The title reads "density-basic · altair · pyplots.ai" at 28pt with a gray subtitle "Kernel density estimation of test scores across two course levels." Grid lines are extremely subtle (dashed, 0.15 opacity), the view frame border is removed, and domain lines are soft gray.

Score: 91/100

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

Visual Quality (27/30)

  • VQ-01: Text Legibility (7/8) — All font sizes explicitly set: title 28pt, axis titles 22pt, tick labels 18pt, annotations 16pt. All meet thresholds and are readable at 4800×2700. Minor: subtitle at 16pt is proportionally small relative to the 28pt title.
  • VQ-02: No Overlap (6/6) — No overlapping text elements. Peak annotations are well-positioned above curve peaks with dy=-18 offset. Rug plot, axis labels, and annotations all have clear separation.
  • VQ-03: Element Visibility (5/6) — Density curve is clearly visible with 0.45 opacity fill and 2.5px outline. Rug plot ticks overlap in dense clusters around the two peaks (scores 30–45 especially), making individual ticks hard to distinguish — inherent to the data density.
  • VQ-04: Color Accessibility (4/4) — Single-series Python Blue with no colorblind concerns. Good contrast between fill (#306998), outline (#1e4d6e), and background.
  • VQ-05: Layout & Canvas (3/4) — Canvas utilization is good (~55–60%). X-axis domain set to [15, 100] but Altair renders tick labels from 10 due to rounding, leaving a small empty zone (x=10–18) before the curve begins. Margins are balanced overall.
  • VQ-06: Axis Labels & Title (2/2) — "Test Score (points)" includes units. "Probability Density" is descriptive and standard for KDE plots.

Design Excellence (15/20)

  • DE-01: Aesthetic Sophistication (6/8) — Strong, cohesive design: monochromatic Python Blue scheme with intentional darker variant for outline and annotations, gray subtitle for typographic hierarchy, semi-transparent fill. Clearly above library defaults. Not yet FiveThirtyEight-level but professional and polished.
  • DE-02: Visual Refinement (4/6) — Good refinement: view frame removed (strokeWidth=0), grid extremely subtle (dashed, opacity 0.15), domain line softened to gray (#888888). Could go further by removing horizontal grid entirely or using y-only grid.
  • DE-03: Data Storytelling (5/6) — Strong storytelling: bimodal data creates natural visual interest, peak annotations ("Foundational Course" / "Advanced Course") immediately explain the two modes, subtitle provides context. Viewer understands the insight without effort. Could be elevated further with color-differentiated regions or sample-size context.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct KDE/density plot using Altair's built-in transform_density.
  • SC-02: Required Features (4/4) — All spec features present: smooth density curve ✓, filled area with transparency (opacity=0.45) ✓, rug plot along x-axis (mark_tick at datum=0) ✓, appropriate bandwidth (4) ✓.
  • SC-03: Data Mapping (3/3) — X-axis maps to continuous variable (Test Score), Y-axis maps to probability density. All data visible within the domain.
  • SC-04: Title & Legend (3/3) — Title follows exact format "density-basic · altair · pyplots.ai". Single series — no legend needed, correctly omitted.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Bimodal distribution with asymmetric peaks (different heights, widths, sample sizes) demonstrates KDE's ability to reveal complex distribution shapes. Excellent showcase of density estimation vs. histogram.
  • DQ-02: Realistic Context (5/5) — Test scores across two course levels (Foundational/Advanced) is a neutral, educational, real-world scenario. Plausible and comprehensible.
  • DQ-03: Appropriate Scale (4/4) — Scores clipped to 5–100, means at 38 and 72, std devs of 7 and 8. Sample sizes of 200+150=350 total. All realistic for educational test score distributions.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Clean linear flow: Imports → Data → Peaks → Selection → Density → Hover → Annotations → Rug → Combine → Save. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) ensures deterministic output.
  • CQ-03: Clean Imports (2/2) — All three imports (altair, numpy, pandas) are used. No unused imports.
  • CQ-04: Code Elegance (2/2) — Clean, well-organized code with clear comments. Method chaining is idiomatic. Selection-based hover is a standard Altair pattern, not fake functionality.
  • CQ-05: Output & API (1/1) — Saves plot.png with scale_factor=3.0 and interactive plot.html. Current Altair 6.0 API.

Library Mastery (9/10)

  • LM-01: Idiomatic Usage (5/5) — Expert Altair usage: declarative transform_density, proper encoding types (:Q, :N), alt.layer for composition, selection_point with nearest=True, conditional encoding via alt.condition, alt.Title/Scale/Axis configuration. Rug plot properly uses datum=0 instead of hardcoded pixel values.
  • LM-02: Distinctive Features (4/5) — Leverages several Altair-distinctive features: transform_density (server-side KDE in Vega-Lite), selection_point with nearest for interactive hover readout, conditional opacity encoding, invisible hover points driving selection, HTML export with full interactivity. These couldn't be easily replicated in matplotlib/seaborn.

Score Caps Applied

  • None — no cap conditions triggered.

Strengths

  • Bimodal data with peak annotations creates immediate storytelling — viewer instantly understands the two student populations
  • Rug plot properly positioned at datum=0 (fixed from attempt 1's hardcoded pixel value)
  • Excellent use of Altair-distinctive features: declarative selections, conditional encoding, transform_density
  • Clean, refined visual design with cohesive color scheme, subtle grid, and removed view frame
  • Interactive HTML export with nearest-point hover readout adds genuine value beyond static PNG

Weaknesses

  • X-axis domain [15, 100] still renders tick from 10 due to Altair's tick rounding, creating a small empty zone before the data starts
  • Rug plot ticks overlap in dense peak regions (inherent to data density, minor visual issue)
  • Subtitle font size (16pt) is proportionally small relative to the 28pt title on the large canvas

Issues Found

  1. VQ-05 at 3/4: X-axis domain tightened to [15, 100] but Altair's tick generation still shows "10" label
    • Minor: could use alt.Axis(values=[20, 30, ...]) for explicit tick values, but current behavior is acceptable
  2. DE-01 at 6/8: Strong design but not yet FiveThirtyEight-level publication quality
    • The monochromatic scheme is cohesive; further elevation would require more distinctive visual identity

AI Feedback for Next Attempt

Score improved from 87 to 91 — all major issues from attempt 1 resolved. Peak annotations and selection-based interactivity significantly improved storytelling and library mastery. The implementation now demonstrates strong Altair competence with idiomatic patterns.

Verdict: APPROVED

@github-actions github-actions Bot added quality:91 Quality score 91/100 ai-approved Quality OK, ready for merge labels Feb 23, 2026
Copilot AI review requested due to automatic review settings February 23, 2026 23:02
@MarkusNeusinger MarkusNeusinger review requested due to automatic review settings February 23, 2026 23:02
Copilot AI review requested due to automatic review settings February 23, 2026 23:02
@MarkusNeusinger MarkusNeusinger review requested due to automatic review settings February 23, 2026 23:02
@github-actions github-actions Bot merged commit 7f9df95 into main Feb 23, 2026
3 checks passed
@github-actions github-actions Bot deleted the implementation/density-basic/altair branch February 23, 2026 23: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:87 Quality score 87/100 quality:91 Quality score 91/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants