Skip to content

Commit 8d38ae5

Browse files
feat(plotnine): implement line-stepwise (#2609)
## Implementation: `line-stepwise` - plotnine Implements the **plotnine** version of `line-stepwise`. **File:** `plots/line-stepwise/implementations/plotnine.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594559603)* --------- 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 4c4de6e commit 8d38ae5

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
""" pyplots.ai
2+
line-stepwise: Step Line Plot
3+
Library: plotnine 0.15.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 plotnine import aes, element_text, geom_step, ggplot, labs, theme, theme_minimal
10+
11+
12+
# Data - Server CPU utilization showing discrete state changes
13+
np.random.seed(42)
14+
hours = np.arange(0, 24)
15+
# Simulate CPU utilization that changes in discrete steps
16+
base_utilization = np.array(
17+
[
18+
15,
19+
15,
20+
12,
21+
10,
22+
10,
23+
20, # Night/early morning - low usage
24+
45,
25+
65,
26+
75,
27+
80,
28+
85,
29+
80, # Morning ramp-up - high load
30+
70,
31+
75,
32+
80,
33+
85,
34+
90,
35+
85, # Afternoon - peak hours
36+
70,
37+
55,
38+
40,
39+
30,
40+
25,
41+
18, # Evening wind-down
42+
]
43+
)
44+
45+
df = pd.DataFrame({"hour": hours, "cpu_utilization": base_utilization})
46+
47+
# Plot
48+
plot = (
49+
ggplot(df, aes(x="hour", y="cpu_utilization"))
50+
+ geom_step(color="#306998", size=2, direction="hv")
51+
+ labs(x="Hour of Day", y="CPU Utilization (%)", title="line-stepwise · plotnine · pyplots.ai")
52+
+ theme_minimal()
53+
+ theme(
54+
figure_size=(16, 9),
55+
text=element_text(size=14),
56+
axis_title=element_text(size=20),
57+
axis_text=element_text(size=16),
58+
plot_title=element_text(size=24),
59+
panel_grid_major=element_text(color="#cccccc"),
60+
panel_grid_minor=element_text(color="#eeeeee"),
61+
)
62+
)
63+
64+
# Save
65+
plot.save("plot.png", dpi=300, verbose=False)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: plotnine
2+
specification_id: line-stepwise
3+
created: '2025-12-30T10:37:30Z'
4+
updated: '2025-12-30T10:43:58Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594559603
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 0.15.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotnine/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotnine/plot_thumb.png
12+
preview_html: null
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent use of geom_step with direction="hv" for proper step function visualization
17+
- Realistic and relatable CPU utilization scenario that perfectly demonstrates discrete
18+
state changes
19+
- Clean grammar of graphics implementation following plotnine best practices
20+
- Well-balanced layout with appropriate text sizing for 4800x2700 output
21+
- Data shows clear daily pattern with morning ramp-up, business hours peak, and
22+
evening wind-down
23+
weaknesses:
24+
- 'Minor: panel_grid_major and panel_grid_minor use element_text() instead of element_line()
25+
- this does not cause visible issues but is technically incorrect for grid styling'

0 commit comments

Comments
 (0)