Skip to content

Commit 84f2303

Browse files
update(band-basic): bokeh — comprehensive quality review
Comprehensive quality review of bokeh band-basic implementation.
1 parent b634f35 commit 84f2303

4 files changed

Lines changed: 61 additions & 38 deletions

File tree

Lines changed: 50 additions & 31 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: bokeh 3.8.1 | Python 3.13.11
4-
Quality: 91/100 | Created: 2025-12-23
3+
Library: bokeh 3.8.2 | Python 3.14
4+
Quality: /100 | Updated: 2026-02-23
55
"""
66

77
import numpy as np
@@ -18,49 +18,68 @@
1818
y_upper = y_center + 1.96 * uncertainty # 95% CI upper bound
1919
y_lower = y_center - 1.96 * uncertainty # 95% CI lower bound
2020

21-
# Create ColumnDataSource for band (patch requires closed polygon)
22-
x_band = np.concatenate([x, x[::-1]])
23-
y_band = np.concatenate([y_upper, y_lower[::-1]])
24-
band_source = ColumnDataSource(data={"x": x_band, "y": y_band})
21+
# Create ColumnDataSource
22+
source = ColumnDataSource(data={"x": x, "y_center": y_center, "y_upper": y_upper, "y_lower": y_lower})
2523

26-
# Create ColumnDataSource for center line
27-
line_source = ColumnDataSource(data={"x": x, "y": y_center})
28-
29-
# Create figure (4800 × 2700 px)
30-
p = figure(width=4800, height=2700, title="band-basic · bokeh · pyplots.ai", x_axis_label="Time", y_axis_label="Value")
24+
# Create figure (4800 x 2700 px)
25+
p = figure(
26+
width=4800,
27+
height=2700,
28+
title="band-basic \u00b7 bokeh \u00b7 pyplots.ai",
29+
x_axis_label="Time (s)",
30+
y_axis_label="Value",
31+
toolbar_location=None,
32+
)
3133

32-
# Plot band (semi-transparent fill)
33-
p.patch(
34+
# Plot band using varea (idiomatic Bokeh band glyph)
35+
p.varea(
3436
x="x",
35-
y="y",
36-
source=band_source,
37+
y1="y_lower",
38+
y2="y_upper",
39+
source=source,
3740
fill_color="#306998",
3841
fill_alpha=0.3,
39-
line_color="#306998",
40-
line_alpha=0.5,
41-
line_width=2,
4242
legend_label="95% Confidence Interval",
4343
)
4444

4545
# Plot center line
46-
p.line(x="x", y="y", source=line_source, line_color="#FFD43B", line_width=4, legend_label="Mean Trend")
46+
p.line(x="x", y="y_center", source=source, line_color="#FFD43B", line_width=6, legend_label="Mean Trend")
47+
48+
# Styling for 4800x2700 px — Bokeh pt renders at CSS scale, need large values
49+
p.title.text_font_size = "96pt"
50+
p.title.text_font_style = "normal"
51+
p.xaxis.axis_label_text_font_size = "72pt"
52+
p.yaxis.axis_label_text_font_size = "72pt"
53+
p.xaxis.major_label_text_font_size = "56pt"
54+
p.yaxis.major_label_text_font_size = "56pt"
55+
56+
# Remove top and right spines
57+
p.outline_line_color = None
58+
p.xaxis.axis_line_color = "#333333"
59+
p.yaxis.axis_line_color = "#333333"
4760

48-
# Styling for 4800×2700 px
49-
p.title.text_font_size = "28pt"
50-
p.xaxis.axis_label_text_font_size = "22pt"
51-
p.yaxis.axis_label_text_font_size = "22pt"
52-
p.xaxis.major_label_text_font_size = "18pt"
53-
p.yaxis.major_label_text_font_size = "18pt"
61+
# Grid styling - subtle solid lines
62+
p.xgrid.grid_line_alpha = 0.15
63+
p.ygrid.grid_line_alpha = 0.15
64+
p.xgrid.grid_line_dash = "solid"
65+
p.ygrid.grid_line_dash = "solid"
5466

55-
# Grid styling
56-
p.grid.grid_line_alpha = 0.3
57-
p.grid.grid_line_dash = [6, 4]
67+
# Remove tick marks, keep labels
68+
p.xaxis.major_tick_line_color = None
69+
p.yaxis.major_tick_line_color = None
70+
p.xaxis.minor_tick_line_color = None
71+
p.yaxis.minor_tick_line_color = None
5872

5973
# Legend styling
60-
p.legend.label_text_font_size = "18pt"
74+
p.legend.label_text_font_size = "56pt"
6175
p.legend.location = "top_left"
6276
p.legend.background_fill_alpha = 0.7
77+
p.legend.border_line_color = None
78+
p.legend.glyph_width = 60
79+
p.legend.glyph_height = 40
80+
p.legend.padding = 20
81+
p.legend.spacing = 12
6382

6483
# Save as PNG and HTML
6584
export_png(p, filename="plot.png")
66-
save(p, filename="plot.html", title="band-basic · bokeh · pyplots.ai")
85+
save(p, filename="plot.html", title="band-basic \u00b7 bokeh \u00b7 pyplots.ai")

plots/band-basic/metadata/bokeh.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: bokeh
22
specification_id: band-basic
33
created: '2025-12-23T09:09:02Z'
4-
updated: '2025-12-23T09:11:03Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-23T13:43:00Z'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20456384474
77
issue: 0
8-
python_version: 3.13.11
9-
library_version: 3.8.1
8+
python_version: '3.14'
9+
library_version: 3.8.2
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/band-basic/bokeh/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/band-basic/bokeh/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/band-basic/bokeh/plot.html
13-
quality_score: 91
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)