Skip to content

Commit 847f365

Browse files
feat(altair): implement line-filled (#2663)
## Implementation: `line-filled` - altair Implements the **altair** version of `line-filled`. **File:** `plots/line-filled/implementations/altair.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20595334243)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b43602b commit 847f365

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
""" pyplots.ai
2+
line-filled: Filled 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 - Website traffic over a month
13+
np.random.seed(42)
14+
days = np.arange(1, 31)
15+
# Simulate daily visitors with weekly patterns and growth trend
16+
base = 5000 + days * 100 # Growth trend
17+
weekly_pattern = 800 * np.sin(2 * np.pi * days / 7) # Weekly cycle
18+
noise = np.random.normal(0, 300, len(days))
19+
visitors = base + weekly_pattern + noise
20+
visitors = np.maximum(visitors, 1000) # Ensure positive values
21+
22+
df = pd.DataFrame({"Day": days, "Visitors": visitors})
23+
24+
# Create filled line chart (area chart)
25+
chart = (
26+
alt.Chart(df)
27+
.mark_area(
28+
line={"color": "#306998", "strokeWidth": 3},
29+
color=alt.Gradient(
30+
gradient="linear",
31+
stops=[
32+
alt.GradientStop(color="rgba(48, 105, 152, 0.4)", offset=0),
33+
alt.GradientStop(color="rgba(48, 105, 152, 0.1)", offset=1),
34+
],
35+
x1=1,
36+
x2=1,
37+
y1=1,
38+
y2=0,
39+
),
40+
)
41+
.encode(
42+
x=alt.X("Day:Q", title="Day of Month", axis=alt.Axis(labelFontSize=18, titleFontSize=22)),
43+
y=alt.Y("Visitors:Q", title="Daily Visitors", axis=alt.Axis(labelFontSize=18, titleFontSize=22)),
44+
tooltip=["Day:Q", "Visitors:Q"],
45+
)
46+
.properties(
47+
width=1600, height=900, title=alt.Title("line-filled · altair · pyplots.ai", fontSize=28, anchor="middle")
48+
)
49+
.configure_axis(grid=True, gridOpacity=0.3, gridDash=[3, 3])
50+
.configure_view(strokeWidth=0)
51+
)
52+
53+
# Save as PNG and HTML
54+
chart.save("plot.png", scale_factor=3.0)
55+
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-filled
3+
created: '2025-12-30T11:22:20Z'
4+
updated: '2025-12-30T11:30:00Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20595334243
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-filled/altair/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-filled/altair/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-filled/altair/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent use of Altair gradient feature for the fill, creating a visually appealing
17+
fade effect
18+
- Line property within mark_area ensures the line is visible on top of the fill
19+
- Realistic website traffic data with growth trend and weekly cyclical patterns
20+
- Clean, declarative Altair code following library conventions
21+
- Proper font sizes for high-resolution output (scale_factor=3.0)
22+
- Tooltips included for interactivity
23+
weaknesses:
24+
- Axis labels lack units (could be "Daily Visitors (count)" or "Day of Month (day)")
25+
- The gradient direction could potentially be inverted (darker at line, lighter
26+
toward baseline) to better emphasize the data

0 commit comments

Comments
 (0)