Skip to content

Commit 3e86c95

Browse files
feat(letsplot): implement line-animated-progressive (#3277)
## Implementation: `line-animated-progressive` - letsplot Implements the **letsplot** version of `line-animated-progressive`. **File:** `plots/line-animated-progressive/implementations/letsplot.py` **Parent Issue:** #3238 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20795233520)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f373fe3 commit 3e86c95

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""pyplots.ai
2+
line-animated-progressive: Animated Line Plot Over Time
3+
Library: lets-plot | Python 3.13
4+
Quality: pending | Created: 2025-01-07
5+
"""
6+
7+
import numpy as np
8+
import pandas as pd
9+
from lets_plot import (
10+
LetsPlot,
11+
aes,
12+
element_line,
13+
element_rect,
14+
element_text,
15+
facet_wrap,
16+
geom_line,
17+
geom_point,
18+
ggplot,
19+
ggsize,
20+
labs,
21+
scale_color_manual,
22+
scale_x_continuous,
23+
theme,
24+
theme_minimal,
25+
)
26+
from lets_plot.export import ggsave
27+
28+
29+
LetsPlot.setup_html()
30+
31+
# Data - Monthly website traffic over 2 years
32+
np.random.seed(42)
33+
n_points = 24
34+
months = np.arange(1, n_points + 1)
35+
36+
# Traffic with seasonal pattern and growth trend
37+
base_traffic = 50000
38+
trend = np.linspace(0, 30000, n_points)
39+
seasonal = 8000 * np.sin(2 * np.pi * months / 12)
40+
noise = np.random.normal(0, 3000, n_points)
41+
traffic = base_traffic + trend + seasonal + noise
42+
43+
# Create small multiples showing progressive stages
44+
stages = [6, 12, 18, 24]
45+
stage_labels = ["1. Q2 2023", "2. Q4 2023", "3. Q2 2024", "4. Complete"]
46+
47+
dfs = []
48+
for stage, label in zip(stages, stage_labels, strict=True):
49+
stage_df = pd.DataFrame(
50+
{
51+
"month": months[:stage],
52+
"traffic": traffic[:stage],
53+
"stage": label,
54+
"is_latest": [False] * (stage - 1) + [True],
55+
}
56+
)
57+
dfs.append(stage_df)
58+
59+
df = pd.concat(dfs, ignore_index=True)
60+
61+
# Create plot with small multiples
62+
plot = (
63+
ggplot(df, aes(x="month", y="traffic"))
64+
+ geom_line(color="#306998", size=2, alpha=0.9)
65+
+ geom_point(aes(color="is_latest"), size=4, alpha=0.8)
66+
+ scale_color_manual(values={"True": "#FFD43B", "False": "#306998"}, guide="none")
67+
+ facet_wrap("stage", ncol=2)
68+
+ scale_x_continuous(breaks=[6, 12, 18, 24], labels=["Jun '23", "Dec '23", "Jun '24", "Dec '24"])
69+
+ labs(title="line-animated-progressive \u00b7 letsplot \u00b7 pyplots.ai", x="Time Period", y="Monthly Visitors")
70+
+ theme_minimal()
71+
+ theme(
72+
plot_title=element_text(size=26),
73+
axis_title=element_text(size=20),
74+
axis_text=element_text(size=16),
75+
strip_text=element_text(size=18),
76+
legend_text=element_text(size=16),
77+
panel_grid=element_line(color="#CCCCCC", size=0.4, linetype="dashed"),
78+
panel_background=element_rect(fill="#FAFAFA"),
79+
)
80+
+ ggsize(1600, 900)
81+
)
82+
83+
# Save PNG (scale=3 gives 4800x2700)
84+
ggsave(plot, "plot.png", path=".", scale=3)
85+
86+
# Save HTML for interactivity
87+
ggsave(plot, "plot.html", path=".")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Per-library metadata for letsplot implementation of line-animated-progressive
2+
# Auto-generated by impl-generate.yml
3+
4+
library: letsplot
5+
specification_id: line-animated-progressive
6+
created: '2026-01-07T20:31:31Z'
7+
updated: '2026-01-07T20:31:31Z'
8+
generated_by: claude-opus-4-5-20251101
9+
workflow_run: 20795233520
10+
issue: 3238
11+
python_version: 3.13.11
12+
library_version: 4.8.2
13+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-animated-progressive/letsplot/plot.png
14+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-animated-progressive/letsplot/plot_thumb.png
15+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-animated-progressive/letsplot/plot.html
16+
quality_score: null
17+
review:
18+
strengths: []
19+
weaknesses: []

0 commit comments

Comments
 (0)