Skip to content

Commit 41d425b

Browse files
update(band-basic): plotnine — comprehensive quality review
Comprehensive quality review of plotnine band-basic implementation.
1 parent b634f35 commit 41d425b

4 files changed

Lines changed: 40 additions & 30 deletions

File tree

plots/band-basic/implementations/plotnine.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
band-basic: Basic Band Plot
3-
Library: plotnine 0.15.2 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-23
3+
Library: plotnine 0.15.3 | Python 3.14
4+
Quality: /100 | Updated: 2026-02-23
55
"""
66

77
import numpy as np
@@ -10,6 +10,7 @@
1010
aes,
1111
element_blank,
1212
element_line,
13+
element_rect,
1314
element_text,
1415
geom_line,
1516
geom_ribbon,
@@ -20,34 +21,34 @@
2021
)
2122

2223

23-
# Data - time series with 95% confidence interval (model predictions)
24+
# Data - sensor readings with 95% confidence interval
2425
np.random.seed(42)
25-
n_points = 50
26-
x = np.linspace(0, 10, n_points)
26+
n_points = 60
27+
days = np.linspace(0, 30, n_points)
2728

28-
# Generate central trend with curvature
29-
y_center = 3 * np.sin(0.5 * x) + 0.3 * x + 5
30-
31-
# Uncertainty grows with x (heteroscedastic - realistic for forecasts)
32-
uncertainty = 0.5 + 0.15 * x
29+
# Central trend: temperature rising then stabilizing (realistic sensor pattern)
30+
temperature = 18 + 4 * (1 - np.exp(-0.15 * days)) + 1.5 * np.sin(0.4 * days)
3331
noise = np.random.normal(0, 0.3, n_points)
34-
y_center = y_center + noise
32+
temperature = temperature + noise
33+
34+
# Uncertainty narrows as model calibrates, then widens for extrapolation
35+
uncertainty = 1.8 * np.exp(-0.08 * days) + 0.3 + 0.04 * np.maximum(days - 20, 0)
3536

36-
# Confidence band boundaries (95% CI uses 1.96 standard errors)
37-
y_lower = y_center - 1.96 * uncertainty
38-
y_upper = y_center + 1.96 * uncertainty
37+
# Confidence band boundaries (95% CI)
38+
temp_lower = temperature - 1.96 * uncertainty
39+
temp_upper = temperature + 1.96 * uncertainty
3940

40-
df = pd.DataFrame({"x": x, "y_center": y_center, "y_lower": y_lower, "y_upper": y_upper})
41+
df = pd.DataFrame({"days": days, "temperature": temperature, "temp_lower": temp_lower, "temp_upper": temp_upper})
4142

4243
# Plot
4344
plot = (
44-
ggplot(df, aes(x="x"))
45-
+ geom_ribbon(aes(ymin="y_lower", ymax="y_upper"), fill="#306998", alpha=0.3)
46-
+ geom_line(aes(y="y_center"), color="#306998", size=2)
45+
ggplot(df, aes(x="days"))
46+
+ geom_ribbon(aes(ymin="temp_lower", ymax="temp_upper"), fill="#306998", alpha=0.25)
47+
+ geom_line(aes(y="temperature"), color="#306998", size=2.5)
4748
+ labs(
48-
x="Time",
49-
y="Predicted Value",
50-
title="Model Forecast with 95% Confidence Interval · band-basic · plotnine · pyplots.ai",
49+
x="Time (days)",
50+
y="Temperature (\u00b0C)",
51+
title="Sensor Calibration Forecast \u00b7 band-basic \u00b7 plotnine \u00b7 pyplots.ai",
5152
)
5253
+ theme_minimal()
5354
+ theme(
@@ -56,8 +57,13 @@
5657
axis_title=element_text(size=20),
5758
axis_text=element_text(size=16),
5859
plot_title=element_text(size=24),
59-
panel_grid_major=element_line(color="#cccccc", size=0.5, alpha=0.3),
60+
panel_grid_major_y=element_line(color="#cccccc", size=0.5, alpha=0.2),
61+
panel_grid_major_x=element_blank(),
6062
panel_grid_minor=element_blank(),
63+
panel_border=element_blank(),
64+
axis_line_x=element_line(color="#333333", size=0.5),
65+
axis_line_y=element_line(color="#333333", size=0.5),
66+
plot_background=element_rect(fill="white", color="none"),
6167
)
6268
)
6369

plots/band-basic/metadata/plotnine.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: plotnine
22
specification_id: band-basic
33
created: '2025-12-23T09:08:40Z'
4-
updated: '2025-12-23T09:10:54Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-23T13:41:00Z'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20456385974
77
issue: 0
8-
python_version: 3.13.11
9-
library_version: 0.15.2
8+
python_version: '3.14'
9+
library_version: 0.15.3
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/band-basic/plotnine/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/band-basic/plotnine/plot_thumb.png
1212
preview_html: null
13-
quality_score: 92
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques:

plots/band-basic/specification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A band plot displays a filled region between two boundary lines, commonly used t
1616
- `x` (numeric) - Independent variable, often representing time or sequence
1717
- `y_lower` (numeric) - Lower boundary values defining the bottom of the band
1818
- `y_upper` (numeric) - Upper boundary values defining the top of the band
19-
- `y_center` (numeric, optional) - Central trend line values (mean/median)
19+
- `y_center` (numeric) - Central trend line values (mean/median), shown as a contrasting line
2020
- Size: 20-200 data points
2121
- Example: Time series with 95% confidence interval bounds
2222

plots/band-basic/specification.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Basic Band Plot
66

77
# Specification tracking
88
created: 2025-12-15T20:42:54Z
9-
updated: 2025-12-15T20:42:54Z
9+
updated: 2026-02-23T12:00:00Z
1010
issue: 979
1111
suggested: MarkusNeusinger
1212

@@ -18,10 +18,14 @@ tags:
1818
data_type:
1919
- numeric
2020
- continuous
21+
- timeseries
2122
domain:
2223
- statistics
2324
- science
25+
- general
26+
- engineering
2427
features:
2528
- basic
2629
- confidence-interval
2730
- uncertainty
31+
- 2d

0 commit comments

Comments
 (0)