Skip to content

feat(altair): implement line-stress-strain#5126

Merged
github-actions[bot] merged 6 commits intomainfrom
implementation/line-stress-strain/altair
Mar 20, 2026
Merged

feat(altair): implement line-stress-strain#5126
github-actions[bot] merged 6 commits intomainfrom
implementation/line-stress-strain/altair

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: line-stress-strain - altair

Implements the altair version of line-stress-strain.

File: plots/line-stress-strain/implementations/altair.py

Parent Issue: #4413


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 20, 2026

AI Review - Attempt 1/3

Image Description

The plot displays a mild steel tensile test stress-strain curve rendered as a blue line (#306998) on a clean white background. The x-axis shows "Engineering Strain" (ranging from -0.01 to ~0.39) and the y-axis shows "Engineering Stress (MPa)" (0 to ~440). The title reads "Mild Steel Tensile Test · line-stress-strain · altair · pyplots.ai" in dark text at the top. Three colored marker dots highlight critical points: an orange/brown dot at the Yield Point (~0.003, 250 MPa), a dark red dot at UTS (~0.22, 400 MPa), and a green dot at Fracture (~0.35, 280 MPa). Each point has a bold colored label. Gray italic region labels ("Elastic", "Strain Hardening", "Necking") appear across the top. A dashed gray line shows the 0.2% offset method with a "0.2% offset" label near the bottom. A blue bold annotation reads "E = 210,000 MPa" in the elastic region. The curve shows the classic pattern: steep elastic rise, yield plateau, gradual strain hardening to UTS peak, then necking decline to fracture. No grid lines are present; axes have subtle gray domain lines and ticks.

Score: 84/100

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

Visual Quality (24/30)

  • VQ-01: Text Legibility (7/8) - Font sizes explicitly set (title 28, axis title 22, axis labels 18, annotations 16-17). All readable. The "0.2% offset" label at 14pt is slightly small but still legible.
  • VQ-02: No Overlap (4/6) - The elastic/yield region at the far left is quite crowded. The "Elastic" region label, yield point dot, yield label, modulus annotation, and 0.2% offset label are all compressed into a narrow horizontal band due to the tiny elastic strain range (~0.001). Labels don't directly overlap each other but the area feels cluttered.
  • VQ-03: Element Visibility (5/6) - Main curve is well-visible at strokeWidth=3. Key points at size=400 with white stroke are prominent. The 0.2% offset dashed line is very short and barely distinguishable from the elastic region of the main curve due to the compressed x-scale.
  • VQ-04: Color Accessibility (3/4) - Orange, dark red, and green markers are reasonably distinguishable but not an ideal colorblind-safe palette. The orange-red pairing could be difficult for some color vision deficiencies.
  • VQ-05: Layout & Canvas (3/4) - Good proportions at 1600×900. Plot fills the canvas well. The elastic region is extremely compressed (strain 0 to 0.001 occupies <1% of x-axis width) making that portion hard to inspect, though this is physically accurate.
  • VQ-06: Axis Labels & Title (2/2) - "Engineering Strain" and "Engineering Stress (MPa)" — descriptive with units.

Design Excellence (14/20)

  • DE-01: Aesthetic Sophistication (5/8) - Custom color palette with Python Blue for the main curve, distinct warm/cool colors for key points. Clean typography with intentional sizing hierarchy. Above library defaults but not quite publication-level polish.
  • DE-02: Visual Refinement (4/6) - Grid disabled, view stroke removed, axis domain/tick colors set to subtle gray (#aaaaaa) with thin widths. Good whitespace around the plot. Axis labels in muted colors ([area-basic] plotnine implementation #333, feat(plotly): implement donut-labeled #555). Some refinement visible.
  • DE-03: Data Storytelling (5/6) - Strong storytelling: region labels guide the viewer through material behavior phases, key points mark the engineering-significant locations, the 0.2% offset method is illustrated, and Young's modulus is annotated. The viewer can immediately understand the material's mechanical properties.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) - Correct line chart showing stress-strain curve.
  • SC-02: Required Features (4/4) - All spec features present: region labels (elastic, strain hardening, necking), critical points (yield, UTS, fracture), 0.2% offset line, Young's modulus annotation.
  • SC-03: Data Mapping (3/3) - X=strain, Y=stress, correctly mapped. All data visible.
  • SC-04: Title & Legend (3/3) - Title follows format with descriptive prefix. No traditional legend but direct labeling of points is superior for this use case.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) - Shows all distinct regions: elastic, yield plateau, strain hardening, necking, and fracture. The yield plateau with realistic noise adds authenticity.
  • DQ-02: Realistic Context (5/5) - Mild steel tensile test — a real, neutral engineering scenario.
  • DQ-03: Appropriate Scale (4/4) - E=210 GPa, yield=250 MPa, UTS=400 MPa, fracture strain=0.35 — all realistic values for mild steel.

Code Quality (9/10)

  • CQ-01: KISS Structure (3/3) - Linear flow: imports → data generation → chart layers → combine → save. No functions or classes.
  • CQ-02: Reproducibility (2/2) - np.random.seed(42) set.
  • CQ-03: Clean Imports (2/2) - altair, numpy, pandas — all used.
  • CQ-04: Code Elegance (1/2) - Slightly verbose: three separate chart objects for yield_label, uts_label, fracture_label could be a single text mark with color encoding. The label_offsets DataFrame is created but then individual rows are sliced out separately.
  • CQ-05: Output & API (1/1) - Saves plot.png and plot.html. Current Altair API.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) - Good use of alt.layer() composition, proper encoding types (:Q, :N), alt.Scale for color mapping, alt.Title, .configure_axis(). Could improve by using alt.Color encoding for labels instead of separate chart objects.
  • LM-02: Distinctive Features (3/5) - Uses tooltips (interactive hover info), .interactive() for zoom/pan, and dual HTML+PNG export. These are distinctive Altair features but fairly standard usage.

Score Caps Applied

  • None

Strengths

  • Excellent spec compliance — all required features (region labels, critical points, offset line, modulus annotation) are present and well-placed
  • Strong data storytelling with clear visual hierarchy guiding the viewer through material behavior phases
  • Realistic mild steel data with appropriate noise in the yield plateau and strain hardening regions
  • Clean visual design with disabled grid, subtle axis styling, and good color choices
  • Good use of Altair layer composition and interactive features (tooltips, zoom/pan)

Weaknesses

  • Left side of the plot is crowded — the elastic region occupies <1% of the x-axis, compressing all elastic-region annotations into a tiny horizontal band
  • Color palette for key points (orange, dark red, green) could be improved for colorblind accessibility
  • Repetitive code pattern for individual point labels — three separate chart objects instead of a single text mark with color encoding
  • The 0.2% offset dashed line is barely visible due to the compressed elastic region scale

Issues Found

  1. VQ-02 MODERATE: Crowded annotations in the elastic/yield region — five visual elements (elastic label, yield dot, yield label, modulus text, offset label) compete for space in <1% of the x-axis width
    • Fix: Consider using a non-linear x-axis break or inset detail view for the elastic region, or reposition some annotations to less crowded areas
  2. VQ-04 MINOR: Orange (#C46210) and dark red (#8B1A1A) key point colors may be hard to distinguish for colorblind users
    • Fix: Use a more distinct palette, e.g., replace dark red with a deep blue or purple
  3. CQ-04 MINOR: Three separate chart objects for point labels is repetitive
    • Fix: Use a single alt.Chart with color encoding mapped to the Label field
  4. LM-01 MINOR: Could leverage Altair's encoding system more fully for labels instead of manual chart-per-label approach
    • Fix: Combine labels into one mark_text layer with conditional color encoding

AI Feedback for Next Attempt

The implementation scores well on spec compliance and data quality (perfect scores). To reach 90+: (1) Address the crowded elastic region — consider repositioning the "E = 210,000 MPa" and "Yield Point" labels to less congested areas, or slightly exaggerating the elastic strain range for visual clarity. (2) Improve color accessibility by replacing the orange/dark-red pairing with more distinguishable colors. (3) Consolidate the three separate label chart objects into a single text mark with color encoding for cleaner code and better Altair idiom usage.

Verdict: REJECTED

@github-actions github-actions bot added quality:84 Quality score 84/100 ai-rejected Quality not OK, triggers update labels Mar 20, 2026
@github-actions github-actions bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Mar 20, 2026
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 Mar 20, 2026

AI Review - Attempt 2/3

Image Description

The plot displays an engineering stress-strain curve for mild steel tensile testing. The main curve is rendered as a solid blue (#306998) line starting from the origin, rising steeply through a nearly vertical elastic region, transitioning through a yield plateau near 250 MPa, curving upward through strain hardening to a peak (UTS) around 400 MPa at ~0.22 strain, then declining through necking to fracture at ~280 MPa and ~0.35 strain. Three key points are marked with large filled circles: Yield Point (orange, #D4760A) near the elastic-plastic transition, UTS (purple, #5B3794) at the peak, and Fracture (teal, #1B9E77) at the end. Region labels ("Elastic", "Strain Hardening", "Necking") appear in italic gray at the top, separated by subtle dashed vertical lines. A dashed gray 0.2% offset line is drawn parallel to the elastic slope. Young's modulus "E = 210,000 MPa" is annotated in blue with a connector line to the elastic slope. Connector lines link displaced labels to their points. The title reads "Mild Steel Tensile Test · line-stress-strain · altair · pyplots.ai" with a gray subtitle. Axes are labeled "Engineering Strain" and "Engineering Stress (MPa)". No grid is shown; axes have subtle gray domain lines and ticks.

Score: 90/100

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

Visual Quality (27/30)

  • VQ-01: Text Legibility (7/8) — All font sizes explicitly set (title=28, subtitle=16, axes=22, ticks=18, annotations=15-17). All text readable; annotation text slightly smaller than ideal but clear.
  • VQ-02: No Overlap (5/6) — Minor visual density in the elastic region where the slope line, offset line, yield marker, and labels converge. Labels are displaced with connectors to avoid direct overlap.
  • VQ-03: Element Visibility (6/6) — Main curve strokeWidth=3 is well visible. Key points at size=450 with white stroke are prominent and easy to spot.
  • VQ-04: Color Accessibility (4/4) — Orange, purple, and teal for key points are highly distinguishable and colorblind-safe. Good contrast against blue curve and white background.
  • VQ-05: Layout & Canvas (3/4) — Good overall canvas utilization. The elastic region (strain 0–0.002) is compressed into ~3% of the x-axis, cramming several annotations into a tight space. Physically accurate but visually suboptimal.
  • VQ-06: Axis Labels & Title (2/2) — "Engineering Strain" and "Engineering Stress (MPa)" — descriptive with units.

Design Excellence (16/20)

  • DE-01: Aesthetic Sophistication (6/8) — Strong design with intentional color palette (orange/purple/teal for key points), hierarchical typography (title > subtitle > axis > annotations), connector lines for displaced labels, and region separators. Clearly above defaults.
  • DE-02: Visual Refinement (5/6) — Grid disabled, view stroke removed, domain/tick colors set to subtle gray (#aaaaaa), axis label colors differentiated (#333333/#555555). Clean, refined appearance with generous whitespace.
  • DE-03: Data Storytelling (5/6) — Region labels at top guide the viewer through elastic → hardening → necking progression. Key points (yield, UTS, fracture) create clear focal points. Young's modulus and 0.2% offset method are annotated to explain the engineering significance. Strong visual hierarchy.

Spec Compliance (14/15)

  • SC-01: Plot Type (5/5) — Correct line chart showing stress-strain curve.
  • SC-02: Required Features (4/4) — All spec features present: region labels (elastic, strain hardening, necking), yield point with 0.2% offset method, UTS marking, fracture point, Young's modulus annotation with slope line, 0.2% offset line.
  • SC-03: Data Mapping (3/3) — X=strain, Y=stress correctly assigned. Axes show full data range with appropriate padding.
  • SC-04: Title & Legend (2/3) — Title includes spec-id, library, and pyplots.ai but adds descriptive prefix ("Mild Steel Tensile Test") deviating from exact {spec-id} · {library} · pyplots.ai format. Legend hidden in favor of direct labeling (appropriate choice).

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Shows all distinct regions: elastic (steep rise), yield plateau (flat with noise), strain hardening (concave curve), and necking (decline to fracture). Complete coverage of stress-strain behavior.
  • DQ-02: Realistic Context (5/5) — Mild steel tensile test — a classic, neutral, real-world engineering scenario used in materials science education and industry.
  • DQ-03: Appropriate Scale (4/4) — Young's modulus 210 GPa, yield strength 250 MPa, UTS 400 MPa, fracture strain 0.35 — all realistic values for mild steel.

Code Quality (9/10)

  • CQ-01: KISS Structure (3/3) — Flat script: imports → data generation → chart layers → combine → save. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set at the start.
  • CQ-03: Clean Imports (2/2) — altair, numpy, pandas — all actively used.
  • CQ-04: Code Elegance (1/2) — Somewhat verbose with many separate DataFrames for labels, connectors, and annotations. Functional but could be more concise.
  • CQ-05: Output & API (1/1) — Saves as plot.png and plot.html. Uses current Altair API.

Library Mastery (9/10)

  • LM-01: Idiomatic Usage (5/5) — Excellent use of Altair's declarative grammar: layered composition with alt.layer(), encoding channels, alt.Scale for color mapping, alt.Title with subtitle, configure_axis/configure_view for styling. Textbook Altair.
  • LM-02: Distinctive Features (4/5) — Uses selection_point with nearest=True for interactive point highlighting, tooltips on curve and key points, .interactive() for zoom/pan, and dual HTML+PNG export. These leverage Altair's interactive strengths.

Score Caps Applied

  • None — no caps triggered.

Strengths

  • Comprehensive engineering story: all required regions, key points, and annotations are present and well-positioned
  • Colorblind-safe palette with distinct orange/purple/teal markers against blue curve
  • Strong use of Altair's interactive features (selection, tooltips, zoom/pan) with HTML export
  • Region labels with separators at the top provide clear structural guidance
  • Connector lines for displaced labels prevent overlap while maintaining association

Weaknesses

  • Elastic region compressed into ~3% of x-axis, cramming yield-related annotations into tight space
  • Title format adds descriptive prefix rather than using exact spec format
  • Code is verbose with many small DataFrames for individual annotation elements

Issues Found

  1. SC-04 MINOR: Title adds "Mild Steel Tensile Test" prefix before spec-id format
    • Fix: Use exact format line-stress-strain · altair · pyplots.ai or keep descriptive text as subtitle only
  2. CQ-04 MINOR: Excessive DataFrames for annotations (connector_df, label_df, modulus_label_df, etc.)
    • Fix: Could consolidate some annotation DataFrames where feasible

AI Feedback for Next Attempt

Strong implementation that meets the approval threshold. The plot effectively communicates the engineering stress-strain story with clear annotations, colorblind-safe design, and good use of Altair's interactive capabilities. Minor improvements possible: consolidate annotation DataFrames and use exact title format.

Verdict: APPROVED

@github-actions github-actions bot added quality:90 Quality score 90/100 ai-approved Quality OK, ready for merge labels Mar 20, 2026
@github-actions github-actions bot merged commit ec605f2 into main Mar 20, 2026
3 checks passed
@github-actions github-actions bot deleted the implementation/line-stress-strain/altair branch March 20, 2026 21:36
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:84 Quality score 84/100 quality:90 Quality score 90/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants