Skip to content

Commit c6a2403

Browse files
feat(altair): implement line-stepwise (#2632)
## Implementation: `line-stepwise` - altair Implements the **altair** version of `line-stepwise`. **File:** `plots/line-stepwise/implementations/altair.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594559674)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 0fd862f commit c6a2403

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
""" pyplots.ai
2+
line-stepwise: Step Line Plot
3+
Library: altair 6.0.0 | Python 3.13.11
4+
Quality: 92/100 | Created: 2025-12-30
5+
"""
6+
7+
import altair as alt
8+
import numpy as np
9+
import pandas as pd
10+
11+
12+
# Data - Daily temperature readings that change discretely
13+
np.random.seed(42)
14+
days = np.arange(0, 20)
15+
# Temperature values that step discretely (simulating daily high temperature readings)
16+
base_temp = 22
17+
temps = base_temp + np.cumsum(np.random.choice([-2, -1, 0, 1, 2], size=20))
18+
19+
df = pd.DataFrame({"Day": days, "Temperature (°C)": temps})
20+
21+
# Create step line chart using interpolate='step-after'
22+
chart = (
23+
alt.Chart(df)
24+
.mark_line(interpolate="step-after", strokeWidth=4, color="#306998")
25+
.encode(
26+
x=alt.X("Day:Q", title="Day", axis=alt.Axis(labelFontSize=18, titleFontSize=22)),
27+
y=alt.Y(
28+
"Temperature (°C):Q",
29+
title="Temperature (°C)",
30+
scale=alt.Scale(zero=False),
31+
axis=alt.Axis(labelFontSize=18, titleFontSize=22),
32+
),
33+
tooltip=["Day", "Temperature (°C)"],
34+
)
35+
.properties(
36+
width=1600, height=900, title=alt.Title("line-stepwise · altair · pyplots.ai", fontSize=28, anchor="middle")
37+
)
38+
.configure_axis(grid=True, gridOpacity=0.3, gridDash=[4, 4])
39+
.configure_view(strokeWidth=0)
40+
)
41+
42+
# Save as PNG (1600 × 900 * 3 = 4800 × 2700 px)
43+
chart.save("plot.png", scale_factor=3.0)
44+
45+
# Save as HTML for interactivity
46+
chart.save("plot.html")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: altair
2+
specification_id: line-stepwise
3+
created: '2025-12-30T10:39:38Z'
4+
updated: '2025-12-30T10:50:06Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594559674
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 6.0.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/altair/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/altair/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/altair/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent use of Altair declarative grammar with proper encoding types (:Q for
17+
quantitative)
18+
- Clean implementation of step-after interpolation which clearly demonstrates the
19+
stepwise behavior
20+
- 'Good use of Altair-specific features: tooltips, configure_axis for grid styling,
21+
Title object with fontSize'
22+
- Proper scale configuration with zero=False to focus on the data range
23+
- Code is clean, well-organized, and follows KISS principles
24+
weaknesses:
25+
- Data shows predominantly upward trend; could benefit from more varied step patterns
26+
(both increases and decreases) to better demonstrate discrete state changes

0 commit comments

Comments
 (0)