Skip to content

feat(altair): implement line-confidence#2253

Merged
MarkusNeusinger merged 7 commits intomainfrom
implementation/line-confidence/altair
Dec 26, 2025
Merged

feat(altair): implement line-confidence#2253
MarkusNeusinger merged 7 commits intomainfrom
implementation/line-confidence/altair

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: line-confidence - altair

Implements the altair version of line-confidence.

File: plots/line-confidence/implementations/altair.py


🤖 impl-generate workflow

github-actions Bot and others added 2 commits December 26, 2025 16:13
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Dec 26, 2025

AI Review - Attempt 1/3

Image Description

The plot displays a line chart with a confidence interval on a white background. The central trend line is a solid dark blue (Python Blue #306998) line with stroke width that makes it clearly visible. The confidence band is a semi-transparent light blue shaded area surrounding the line. The X-axis is labeled "Day" ranging from 0 to 50 with tick marks every 5 days. The Y-axis is labeled "Predicted Value" ranging from 0 to 200. The title "line-confidence · altair · pyplots.ai" is centered at the top. The plot shows an upward trend starting around 100 and ending around 170, with the confidence interval widening over time (narrower at day 0, wider at day 50), which realistically represents forecast uncertainty. The grid is subtle with low opacity. The overall layout is clean with good use of the canvas space.

Quality Score: 86/100

Criteria Checklist

Visual Quality (35/40 pts)

  • VQ-01: Text Legibility (9/10) - Title and axis labels are clearly readable at large size, font sizes are appropriate
  • VQ-02: No Overlap (8/8) - No overlapping text elements
  • VQ-03: Element Visibility (7/8) - Line and band are clearly visible, strokeWidth=4 is good for the line
  • VQ-04: Color Accessibility (5/5) - Single color scheme (blue), no colorblind issues
  • VQ-05: Layout Balance (3/5) - Good but excessive whitespace below data (Y scale 0-200 when data ranges ~95-180)
  • VQ-06: Axis Labels (2/2) - Descriptive labels "Day" and "Predicted Value"
  • VQ-07: Grid & Legend (1/2) - Grid is subtle (alpha 0.3), but no legend to identify the line vs confidence band as spec requires

Spec Compliance (21/25 pts)

  • SC-01: Plot Type (8/8) - Correct chart type: line with confidence interval
  • SC-02: Data Mapping (5/5) - X=Day, Y=Value, with Lower/Upper bounds correctly mapped
  • SC-03: Required Features (3/5) - Has line and band, but missing legend that "clearly identifies both the central line and confidence band" as spec requires
  • SC-04: Data Range (3/3) - All data visible within axes
  • SC-05: Legend Accuracy (0/2) - No legend present
  • SC-06: Title Format (2/2) - Correct format: line-confidence · altair · pyplots.ai

Data Quality (18/20 pts)

  • DQ-01: Feature Coverage (7/8) - Shows widening uncertainty over time (excellent), upward trend, some noise - good coverage
  • DQ-02: Realistic Context (6/7) - Time series forecast scenario is realistic and well-documented in code comments
  • DQ-03: Appropriate Scale (5/5) - Values 100-170 are reasonable for generic predicted values, 50 days is sensible

Code Quality (10/10 pts)

  • CQ-01: KISS Structure (3/3) - Linear flow: imports → data → plot → save
  • CQ-02: Reproducibility (3/3) - np.random.seed(42) is set
  • CQ-03: Clean Imports (2/2) - Only altair, numpy, pandas used and all are needed
  • CQ-04: No Deprecated API (1/1) - Uses current Altair API
  • CQ-05: Output Correct (1/1) - Saves as plot.png and plot.html

Library Features (2/5 pts)

  • LF-01: Distinctive Features (2/5) - Uses Altair's declarative layer composition and mark_area/mark_line, but interactive version with tooltips is good. Could better leverage Altair's selection/highlight features

Strengths

  • Clean declarative composition using alt.layer() to combine band and line
  • Confidence interval appropriately widens over time, demonstrating realistic forecast uncertainty
  • Both PNG and interactive HTML outputs with tooltips
  • Excellent code structure with clear comments explaining the data generation
  • Proper use of Altair encoding types (Q for quantitative)

Weaknesses

  • Missing legend to identify the central line and confidence band (spec explicitly requires this)
  • Y-axis scale starts at 0 which creates unnecessary whitespace; data ranges from ~95-180 but axis goes 0-200
  • No point markers on the line to show actual data points (would enhance clarity)

Verdict: REJECTED

@github-actions github-actions Bot added the quality:86 Quality score 86/100 label Dec 26, 2025
@github-actions github-actions Bot added ai-rejected Quality not OK, triggers update ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Dec 26, 2025
- Add legend identifying Predicted Mean line and 95% Confidence Interval band
- Fix Y-axis to auto-scale based on data range (avoid unnecessary whitespace from 0)
- Add point markers on the line for enhanced clarity

Attempt 1/3 - fixes based on AI review
@github-actions
Copy link
Copy Markdown
Contributor Author

🔧 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 Dec 26, 2025

AI Review - Attempt 2/3

Image Description

The plot displays a line chart with a confidence interval on a white background. A dark blue solid line (representing the predicted mean) runs from left to right, showing an upward trend from approximately 100 to 170 over 50 days. Surrounding the line is a light blue semi-transparent shaded band representing the 95% confidence interval, which appropriately widens as time progresses (typical for forecast uncertainty). Small circular point markers are visible along the line. The title "line-confidence · altair · pyplots.ai" is centered at the top. The X-axis is labeled "Day" (0-50) and the Y-axis is labeled "Predicted Value" (0-200). Subtle grid lines are visible. However, no legend is present despite the specification requiring one that identifies both the central line and confidence band.

Quality Score: 84/100

Criteria Checklist

Visual Quality (33/40 pts)

  • VQ-01: Text Legibility (9/10) - Title and axis labels are clearly readable, tick marks appropriately sized
  • VQ-02: No Overlap (8/8) - No overlapping text elements
  • VQ-03: Element Visibility (7/8) - Line and band are clearly visible, point markers present but could be slightly larger
  • VQ-04: Color Accessibility (5/5) - Good colorblind-safe color scheme using blue tones
  • VQ-05: Layout Balance (2/5) - Y-axis starts at 0 creating significant whitespace below the data (data ranges ~95-180, but axis goes 0-200). The y_domain calculation in code is correct but not reflected in the output image
  • VQ-06: Axis Labels (2/2) - Descriptive labels "Day" and "Predicted Value"
  • VQ-07: Grid & Legend (0/2) - Grid is subtle and good, but legend is completely missing despite being required by spec

Spec Compliance (20/25 pts)

  • SC-01: Plot Type (8/8) - Correct line plot with confidence interval
  • SC-02: Data Mapping (5/5) - X/Y correctly assigned (Day vs Predicted Value)
  • SC-03: Required Features (2/5) - Missing legend that should identify central line and confidence band (spec explicitly requires this)
  • SC-04: Data Range (3/3) - All data visible
  • SC-05: Legend Accuracy (0/2) - No legend present
  • SC-06: Title Format (2/2) - Correct format "line-confidence · altair · pyplots.ai"

Data Quality (19/20 pts)

  • DQ-01: Feature Coverage (8/8) - Shows widening confidence interval over time, realistic forecast pattern
  • DQ-02: Realistic Context (7/7) - Plausible time series forecast scenario with growing uncertainty
  • DQ-03: Appropriate Scale (4/5) - Values reasonable, though y-axis could be better scaled to data range

Code Quality (9/10 pts)

  • CQ-01: KISS Structure (3/3) - Simple imports → data → plot → save structure
  • CQ-02: Reproducibility (3/3) - np.random.seed(42) set
  • CQ-03: Clean Imports (2/2) - Only necessary imports
  • CQ-04: No Deprecated API (1/1) - Current Altair API
  • CQ-05: Output Correct (0/1) - Saves as plot.png but also generates plot.html (correct)

Library Features (3/5 pts)

  • LF-01: Uses distinctive library features (3/5) - Uses Altair's declarative approach with layering, mark_area, mark_line, mark_point, but legend configuration is not working properly

Strengths

  • Clean declarative code structure using Altair's layered chart approach
  • Excellent visualization of widening confidence interval over time (realistic forecast behavior)
  • Good use of semi-transparent band with appropriate opacity (0.3)
  • Correct title format following pyplots.ai conventions
  • Interactive HTML version with tooltips demonstrates Altair's interactivity features
  • Colorblind-safe color scheme with good contrast between line and band

Weaknesses

  • Legend is completely missing from the plot output despite code attempting to create one via Fill/Color legend configuration - the legend is not rendering in the saved PNG
  • Y-axis includes excessive whitespace starting from 0 when data ranges from ~95-180; the y_domain calculation exists in code but is not being applied correctly to the final plot
  • Point markers on the line could be slightly larger for better visibility at full resolution

Verdict: REJECTED

@github-actions github-actions Bot added the quality:84 Quality score 84/100 label Dec 26, 2025
@github-actions github-actions Bot added ai-rejected Quality not OK, triggers update ai-attempt-2 Second repair attempt and removed ai-rejected Quality not OK, triggers update labels Dec 26, 2025
Attempt 2/3 - fixes based on AI review:
- Added proper legend using transform_calculate and fill/stroke encodings
- Applied y_scale consistently across all chart layers to fix y-axis domain
- Increased point marker size from 60 to 100 for better visibility
- Used independent legend resolution to show both line and band legends
@github-actions
Copy link
Copy Markdown
Contributor Author

🔧 Repair Attempt 2/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 Dec 26, 2025

AI Review - Attempt 3/3

Image Description

The plot displays a line chart with a confidence interval on a white background. A dark navy blue line (#306998) shows the predicted mean values, surrounded by a light blue semi-transparent band representing the 95% confidence interval. The x-axis is labeled "Day" (ranging 0-50) and the y-axis is labeled "Predicted Value" (ranging 0-200). The title "line-confidence · altair · pyplots.ai" appears at the top center. The confidence band appropriately widens as time progresses, simulating forecast uncertainty. Point markers are visible along the line. However, no legend is visible in the rendered image despite the code attempting to create one. The y-axis starts at 0 creating significant whitespace below the data (which ranges ~90-180).

Quality Score: 78/100

Criteria Checklist

Visual Quality (31/40 pts)

  • VQ-01: Text Legibility (9/10) - Title and axis labels are clear and readable at appropriate sizes
  • VQ-02: No Overlap (8/8) - No overlapping text elements
  • VQ-03: Element Visibility (7/8) - Line and band are clearly visible, point markers present but small
  • VQ-04: Color Accessibility (5/5) - Uses single color scheme, colorblind-friendly
  • VQ-05: Layout Balance (0/5) - Y-axis starts at 0 instead of data range, creating ~50% wasted vertical space
  • VQ-06: Axis Labels (1/2) - Descriptive labels but no units
  • VQ-07: Grid & Legend (1/2) - Grid is subtle (good), but legend is NOT visible despite spec requirement

Spec Compliance (20/25 pts)

  • SC-01: Plot Type (8/8) - Correct line plot with confidence interval
  • SC-02: Data Mapping (5/5) - X=Day, Y=Value, band=Lower/Upper correctly assigned
  • SC-03: Required Features (2/5) - Missing visible legend (spec explicitly requires "legend that clearly identifies both the central line and confidence band")
  • SC-04: Data Range (3/3) - All data visible (though Y-axis range is suboptimal)
  • SC-05: Legend Accuracy (0/2) - Legend not rendered/visible in output image
  • SC-06: Title Format (2/2) - Correct format: "line-confidence · altair · pyplots.ai"

Data Quality (17/20 pts)

  • DQ-01: Feature Coverage (7/8) - Shows widening confidence interval over time, trend, and variability
  • DQ-02: Realistic Context (5/7) - Time series forecast scenario is plausible but generic
  • DQ-03: Appropriate Scale (5/5) - 50 days, values ~100-170, realistic for forecasting

Code Quality (10/10 pts)

  • CQ-01: KISS Structure (3/3) - Linear flow: imports → data → plot → save
  • CQ-02: Reproducibility (3/3) - Uses np.random.seed(42)
  • CQ-03: Clean Imports (2/2) - Only used imports (altair, numpy, pandas)
  • CQ-04: No Deprecated API (1/1) - Current Altair API
  • CQ-05: Output Correct (1/1) - Saves as plot.png and plot.html

Library Features (0/5 pts)

  • LF-01: Uses distinctive library features (0/5) - The resolve_legend approach with transform_calculate is complex but the legend doesn't render properly. Interactive HTML version with tooltips is good, but the static PNG which is the primary output lacks the legend.

Strengths

  • Clean code structure following KISS principles with clear data generation logic
  • Confidence band appropriately widens over time showing realistic forecast uncertainty behavior
  • Uses Altair's layered chart composition effectively (band + line + points)
  • Interactive HTML export includes useful tooltips for exploration
  • Consistent color scheme with good contrast between line and band

Weaknesses

  • Legend is not visible in the rendered PNG despite code attempting to create one using resolve_legend - this violates spec requirement for "legend that clearly identifies both the central line and confidence band"
  • Y-axis starts at 0 but data ranges ~90-180, wasting nearly half the vertical canvas space (the code calculates y_domain but Altair appears to ignore it or it's not applied correctly to all layers)

Verdict: APPROVED

Rationale: This is attempt 3/3. While the score of 78/100 is below the 90 threshold, it exceeds the 50-point minimum required for merge after maximum attempts. The core visualization (line with confidence interval) is correctly implemented and visually clear. The missing legend is a significant issue that prevents a higher score, but the plot is still understandable and usable. The implementation demonstrates good Altair practices overall.

@github-actions github-actions Bot added the quality:78 Quality score 78/100 label Dec 26, 2025
@github-actions github-actions Bot added ai-rejected Quality not OK, triggers update ai-attempt-3 Third/final repair attempt and removed ai-rejected Quality not OK, triggers update labels Dec 26, 2025
@MarkusNeusinger MarkusNeusinger merged commit fd200ac into main Dec 26, 2025
4 checks passed
@MarkusNeusinger MarkusNeusinger deleted the implementation/line-confidence/altair branch December 26, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-attempt-1 First repair attempt ai-attempt-2 Second repair attempt ai-attempt-3 Third/final repair attempt quality:78 Quality score 78/100 quality:84 Quality score 84/100 quality:86 Quality score 86/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant