Skip to content

Commit 286c531

Browse files
update(band-basic): letsplot — comprehensive quality review
Comprehensive quality review of letsplot band-basic implementation.
1 parent b634f35 commit 286c531

4 files changed

Lines changed: 49 additions & 25 deletions

File tree

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
band-basic: Basic Band Plot
3-
Library: letsplot 4.8.2 | Python 3.13.11
4-
Quality: 93/100 | Created: 2025-12-23
3+
Library: letsplot 4.8.2 | Python 3.14
4+
Quality: /100 | Updated: 2026-02-23
55
"""
66

77
import numpy as np
88
import pandas as pd
99
from lets_plot import (
1010
LetsPlot,
1111
aes,
12+
element_blank,
1213
element_line,
1314
element_text,
1415
geom_line,
@@ -17,41 +18,60 @@
1718
ggsave,
1819
ggsize,
1920
labs,
21+
layer_tooltips,
2022
theme,
2123
theme_minimal,
2224
)
2325

2426

2527
LetsPlot.setup_html()
2628

27-
# Data - time series with 95% confidence interval
29+
# Data - sensor temperature readings with 95% confidence interval
2830
np.random.seed(42)
29-
x = np.linspace(0, 10, 100)
30-
y_center = 2 * np.sin(x) + 0.5 * x # Central trend (sinusoidal + linear growth)
31-
noise_scale = 0.3 + 0.15 * x # Increasing uncertainty over time
32-
y_lower = y_center - 1.96 * noise_scale # 95% CI lower bound
33-
y_upper = y_center + 1.96 * noise_scale # 95% CI upper bound
31+
time_seconds = np.linspace(0, 10, 100)
32+
temp_mean = 2 * np.sin(time_seconds) + 0.5 * time_seconds # Central trend
33+
uncertainty = 0.3 + 0.15 * time_seconds # Growing uncertainty over time
34+
temp_lower = temp_mean - 1.96 * uncertainty # 95% CI lower bound
35+
temp_upper = temp_mean + 1.96 * uncertainty # 95% CI upper bound
3436

35-
df = pd.DataFrame({"x": x, "y_center": y_center, "y_lower": y_lower, "y_upper": y_upper})
37+
df = pd.DataFrame({"time": time_seconds, "mean": temp_mean, "lower": temp_lower, "upper": temp_upper})
3638

3739
# Plot
3840
plot = (
39-
ggplot(df, aes(x="x"))
40-
+ geom_ribbon(aes(ymin="y_lower", ymax="y_upper"), fill="#306998", alpha=0.3)
41-
+ geom_line(aes(y="y_center"), color="#306998", size=1.5)
42-
+ labs(x="Time (s)", y="Value (units)", title="band-basic · letsplot · pyplots.ai")
41+
ggplot(df, aes(x="time"))
42+
+ geom_ribbon(
43+
aes(ymin="lower", ymax="upper"),
44+
fill="#306998",
45+
alpha=0.25,
46+
tooltips=layer_tooltips()
47+
.format("lower", "{.2f}")
48+
.format("upper", "{.2f}")
49+
.line("95% CI")
50+
.line("Upper|@upper")
51+
.line("Lower|@lower"),
52+
)
53+
+ geom_line(
54+
aes(y="mean"),
55+
color="#306998",
56+
size=1.5,
57+
tooltips=layer_tooltips()
58+
.format("mean", "{.2f}")
59+
.format("time", "{.1f}")
60+
.line("Time|@time s")
61+
.line("Mean|@mean"),
62+
)
63+
+ labs(x="Time (s)", y="Value (units)", title="band-basic \u00b7 letsplot \u00b7 pyplots.ai")
4364
+ theme_minimal()
4465
+ theme(
4566
axis_title=element_text(size=20),
4667
axis_text=element_text(size=16),
4768
plot_title=element_text(size=24),
48-
panel_grid=element_line(color="#cccccc", size=0.5),
69+
panel_grid_major=element_line(size=0.3, color="#E0E0E0"),
70+
panel_grid_minor=element_blank(),
4971
)
5072
+ ggsize(1600, 900)
5173
)
5274

53-
# Save PNG (scale=3 gives 4800x2700)
75+
# Save
5476
ggsave(plot, "plot.png", path=".", scale=3)
55-
56-
# Save HTML for interactive version
57-
ggsave(plot, "plot.html", path=".")
77+
plot.to_html("plot.html")

plots/band-basic/metadata/letsplot.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: letsplot
22
specification_id: band-basic
33
created: '2025-12-23T09:08:23Z'
4-
updated: '2025-12-23T09:10:30Z'
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: 20456388290
77
issue: 0
8-
python_version: 3.13.11
8+
python_version: '3.14'
99
library_version: 4.8.2
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/band-basic/letsplot/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/band-basic/letsplot/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/band-basic/letsplot/plot.html
13-
quality_score: 93
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)