Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions plots/line-stepwise/implementations/plotnine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
""" pyplots.ai
line-stepwise: Step Line Plot
Library: plotnine 0.15.2 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-30
"""

import numpy as np
import pandas as pd
from plotnine import aes, element_text, geom_step, ggplot, labs, theme, theme_minimal


# Data - Server CPU utilization showing discrete state changes
np.random.seed(42)
hours = np.arange(0, 24)
# Simulate CPU utilization that changes in discrete steps
base_utilization = np.array(
[
15,
15,
12,
10,
10,
20, # Night/early morning - low usage
45,
65,
75,
80,
85,
80, # Morning ramp-up - high load
70,
75,
80,
85,
90,
85, # Afternoon - peak hours
70,
55,
40,
30,
25,
18, # Evening wind-down
]
)

df = pd.DataFrame({"hour": hours, "cpu_utilization": base_utilization})

# Plot
plot = (
ggplot(df, aes(x="hour", y="cpu_utilization"))
+ geom_step(color="#306998", size=2, direction="hv")
+ labs(x="Hour of Day", y="CPU Utilization (%)", title="line-stepwise · plotnine · pyplots.ai")
+ theme_minimal()
+ theme(
figure_size=(16, 9),
text=element_text(size=14),
axis_title=element_text(size=20),
axis_text=element_text(size=16),
plot_title=element_text(size=24),
panel_grid_major=element_text(color="#cccccc"),
panel_grid_minor=element_text(color="#eeeeee"),
)
)

# Save
plot.save("plot.png", dpi=300, verbose=False)
25 changes: 25 additions & 0 deletions plots/line-stepwise/metadata/plotnine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
library: plotnine
specification_id: line-stepwise
created: '2025-12-30T10:37:30Z'
updated: '2025-12-30T10:43:58Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20594559603
issue: 0
python_version: 3.13.11
library_version: 0.15.2
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotnine/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-stepwise/plotnine/plot_thumb.png
preview_html: null
quality_score: 92
review:
strengths:
- Excellent use of geom_step with direction="hv" for proper step function visualization
- Realistic and relatable CPU utilization scenario that perfectly demonstrates discrete
state changes
- Clean grammar of graphics implementation following plotnine best practices
- Well-balanced layout with appropriate text sizing for 4800x2700 output
- Data shows clear daily pattern with morning ramp-up, business hours peak, and
evening wind-down
weaknesses:
- 'Minor: panel_grid_major and panel_grid_minor use element_text() instead of element_line()
- this does not cause visible issues but is technically incorrect for grid styling'