Skip to content

Commit b9d830d

Browse files
feat(letsplot): implement line-stepwise (#2640)
## Implementation: `line-stepwise` - letsplot Implements the **letsplot** version of `line-stepwise`. **File:** `plots/line-stepwise/implementations/letsplot.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594566810)* --------- 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 975a8aa commit b9d830d

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
""" pyplots.ai
2+
line-stepwise: Step Line Plot
3+
Library: letsplot 4.8.2 | Python 3.13.11
4+
Quality: 92/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pandas as pd
9+
from lets_plot import * # noqa: F403, F401
10+
11+
12+
LetsPlot.setup_html()
13+
14+
# Data - Server Response Time Monitor (discrete state changes)
15+
np.random.seed(42)
16+
hours = np.arange(0, 24)
17+
18+
# Response time that changes in steps (server performance states)
19+
base_response = 50
20+
response_times = [base_response]
21+
22+
for i in range(1, 24):
23+
# Random step changes at certain hours
24+
if i in [6, 9, 12, 15, 18, 21]:
25+
change = np.random.choice([-20, -10, 10, 20, 30])
26+
new_val = max(20, min(150, response_times[-1] + change))
27+
response_times.append(new_val)
28+
else:
29+
response_times.append(response_times[-1])
30+
31+
response_times = np.array(response_times)
32+
33+
df = pd.DataFrame({"hour": hours, "response_time": response_times})
34+
35+
# Plot
36+
plot = (
37+
ggplot(df, aes(x="hour", y="response_time"))
38+
+ geom_step(color="#306998", size=2, direction="hv")
39+
+ geom_point(color="#FFD43B", size=5, shape=21, fill="#FFD43B", stroke=1.5)
40+
+ labs(x="Hour of Day", y="Response Time (ms)", title="line-stepwise · letsplot · pyplots.ai")
41+
+ scale_x_continuous(breaks=list(range(0, 25, 3)))
42+
+ theme_minimal()
43+
+ theme(
44+
plot_title=element_text(size=24, face="bold"),
45+
axis_title=element_text(size=20),
46+
axis_text=element_text(size=16),
47+
panel_grid_major=element_line(color="#CCCCCC", size=0.5),
48+
panel_grid_minor=element_blank(),
49+
)
50+
+ ggsize(1600, 900)
51+
)
52+
53+
# Save PNG (scale 3x for 4800 x 2700 px)
54+
ggsave(plot, "plot.png", scale=3)
55+
56+
# Save HTML for interactive version
57+
ggsave(plot, "plot.html")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
library: letsplot
2+
specification_id: line-stepwise
3+
created: '2025-12-30T10:43:40Z'
4+
updated: '2025-12-30T10:51:52Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594566810
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 4.8.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/letsplot/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/letsplot/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/letsplot/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent step line visualization with clear horizontal-then-vertical transitions
17+
using direction=hv
18+
- Points overlay on steps helps identify exact data points at each hour
19+
- Good color scheme with Python-inspired blue and yellow that is colorblind accessible
20+
- Realistic server response time monitoring scenario that demonstrates discrete
21+
state changes
22+
- Proper title format following spec-id · library · pyplots.ai convention
23+
- Clean KISS code structure with reproducible random seed
24+
- Both PNG and HTML outputs generated correctly
25+
weaknesses:
26+
- Grid line color could be slightly more subtle
27+
- Points at every hour are slightly redundant - could highlight only the change
28+
points
29+
- Data pattern is somewhat predictable with changes only at specific scheduled hours

0 commit comments

Comments
 (0)