Skip to content

Commit e762f62

Browse files
feat(plotly): implement line-stepwise (#2622)
## Implementation: `line-stepwise` - plotly Implements the **plotly** version of `line-stepwise`. **File:** `plots/line-stepwise/implementations/plotly.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594557620)* --------- 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 1d0eab2 commit e762f62

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
""" pyplots.ai
2+
line-stepwise: Step Line Plot
3+
Library: plotly 6.5.0 | Python 3.13.11
4+
Quality: 98/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import plotly.graph_objects as go
9+
10+
11+
# Data - Server response time monitoring (discrete state changes)
12+
np.random.seed(42)
13+
hours = np.arange(0, 24, 1)
14+
response_times = np.array(
15+
[
16+
45,
17+
45,
18+
42,
19+
42,
20+
48,
21+
55,
22+
65,
23+
72,
24+
78,
25+
82, # Morning ramp-up
26+
80,
27+
75,
28+
85,
29+
90,
30+
88,
31+
85,
32+
78,
33+
65,
34+
55,
35+
50, # Afternoon peak
36+
48,
37+
45,
38+
44,
39+
43, # Evening decline
40+
]
41+
)
42+
43+
# Create step line plot
44+
fig = go.Figure()
45+
46+
fig.add_trace(
47+
go.Scatter(
48+
x=hours,
49+
y=response_times,
50+
mode="lines+markers",
51+
line=dict(
52+
shape="hv", # Step: horizontal then vertical
53+
color="#306998",
54+
width=4,
55+
),
56+
marker=dict(size=14, color="#306998", line=dict(color="white", width=2)),
57+
name="Response Time",
58+
hovertemplate="Hour: %{x}<br>Response: %{y} ms<extra></extra>",
59+
)
60+
)
61+
62+
# Layout
63+
fig.update_layout(
64+
title=dict(text="line-stepwise · plotly · pyplots.ai", font=dict(size=28), x=0.5, xanchor="center"),
65+
xaxis=dict(
66+
title=dict(text="Hour of Day", font=dict(size=22)),
67+
tickfont=dict(size=18),
68+
tickmode="linear",
69+
tick0=0,
70+
dtick=2,
71+
range=[-0.5, 23.5],
72+
showgrid=True,
73+
gridcolor="rgba(128, 128, 128, 0.2)",
74+
gridwidth=1,
75+
),
76+
yaxis=dict(
77+
title=dict(text="Response Time (ms)", font=dict(size=22)),
78+
tickfont=dict(size=18),
79+
range=[35, 95],
80+
showgrid=True,
81+
gridcolor="rgba(128, 128, 128, 0.2)",
82+
gridwidth=1,
83+
),
84+
template="plotly_white",
85+
showlegend=False,
86+
margin=dict(l=100, r=80, t=120, b=100),
87+
plot_bgcolor="white",
88+
)
89+
90+
# Save as PNG (4800 x 2700 px)
91+
fig.write_image("plot.png", width=1600, height=900, scale=3)
92+
93+
# Save as HTML for interactivity
94+
fig.write_html("plot.html", include_plotlyjs="cdn")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
library: plotly
2+
specification_id: line-stepwise
3+
created: '2025-12-30T10:38:26Z'
4+
updated: '2025-12-30T10:46:33Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594557620
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 6.5.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotly/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotly/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotly/plot.html
13+
quality_score: 98
14+
review:
15+
strengths:
16+
- Perfect implementation of step function using Plotly shape=hv parameter
17+
- Excellent realistic data scenario (server response time monitoring over 24 hours)
18+
- Clean code following KISS principles with proper font sizes for 4800x2700 output
19+
- Interactive HTML output with custom hover template showing hour and response time
20+
- Well-balanced layout with good canvas utilization
21+
weaknesses:
22+
- 'Minor: Grid/legend criterion loses 2 points due to disabled legend, though acceptable
23+
for single-series plots'

0 commit comments

Comments
 (0)