Skip to content

Commit 23c2396

Browse files
feat(bokeh): implement line-filled (#2674)
## Implementation: `line-filled` - bokeh Implements the **bokeh** version of `line-filled`. **File:** `plots/line-filled/implementations/bokeh.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20595334170)* --------- 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 160eb28 commit 23c2396

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
""" pyplots.ai
2+
line-filled: Filled Line Plot
3+
Library: bokeh 3.8.1 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
from bokeh.io import export_png, save
9+
from bokeh.models import ColumnDataSource, HoverTool
10+
from bokeh.plotting import figure
11+
from bokeh.resources import CDN
12+
13+
14+
# Data - Monthly website traffic over a year
15+
np.random.seed(42)
16+
months = np.arange(1, 13)
17+
# Simulate traffic with seasonal trend (higher in summer/winter holidays)
18+
base_traffic = 50000
19+
seasonal = 15000 * np.sin(2 * np.pi * (months - 3) / 12) # Peak in summer
20+
trend = 2000 * months # Gradual growth
21+
noise = np.random.normal(0, 3000, 12)
22+
traffic = base_traffic + seasonal + trend + noise
23+
traffic = np.maximum(traffic, 0) # Ensure positive values
24+
25+
# Create ColumnDataSource
26+
source = ColumnDataSource(data={"month": months, "traffic": traffic, "traffic_zero": np.zeros(len(months))})
27+
28+
# Create figure
29+
p = figure(
30+
width=4800,
31+
height=2700,
32+
title="line-filled · bokeh · pyplots.ai",
33+
x_axis_label="Month",
34+
y_axis_label="Website Visitors",
35+
)
36+
37+
# Filled area using varea
38+
p.varea(x="month", y1="traffic_zero", y2="traffic", source=source, fill_color="#306998", fill_alpha=0.4)
39+
40+
# Line on top of the fill
41+
p.line(x="month", y="traffic", source=source, line_color="#306998", line_width=4)
42+
43+
# Add points for visual emphasis
44+
p.scatter(x="month", y="traffic", source=source, size=12, color="#306998", fill_alpha=0.8)
45+
46+
# Add hover tool
47+
hover = HoverTool(tooltips=[("Month", "@month"), ("Visitors", "@traffic{0,0}")])
48+
p.add_tools(hover)
49+
50+
# Styling for large canvas
51+
p.title.text_font_size = "28pt"
52+
p.xaxis.axis_label_text_font_size = "22pt"
53+
p.yaxis.axis_label_text_font_size = "22pt"
54+
p.xaxis.major_label_text_font_size = "18pt"
55+
p.yaxis.major_label_text_font_size = "18pt"
56+
57+
# Grid styling
58+
p.xgrid.grid_line_alpha = 0.3
59+
p.ygrid.grid_line_alpha = 0.3
60+
p.xgrid.grid_line_dash = [6, 4]
61+
p.ygrid.grid_line_dash = [6, 4]
62+
63+
# Background
64+
p.background_fill_color = "#fafafa"
65+
p.border_fill_color = "#ffffff"
66+
67+
# X-axis ticks for each month
68+
p.xaxis.ticker = list(range(1, 13))
69+
70+
# Save as PNG and HTML
71+
export_png(p, filename="plot.png")
72+
73+
# Also save interactive HTML
74+
save(p, filename="plot.html", resources=CDN, title="line-filled · bokeh · pyplots.ai")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: bokeh
2+
specification_id: line-filled
3+
created: '2025-12-30T11:23:14Z'
4+
updated: '2025-12-30T11:35:51Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20595334170
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.8.1
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-filled/bokeh/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-filled/bokeh/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-filled/bokeh/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent use of Bokeh's varea glyph for the filled area effect
17+
- Clean implementation with ColumnDataSource for data management
18+
- Interactive HTML output with HoverTool showing formatted visitor counts
19+
- Proper font sizing for the 4800x2700 canvas
20+
- Subtle grid styling with dashed lines and low alpha
21+
- Realistic website traffic scenario with seasonal variation
22+
weaknesses:
23+
- Axis labels lack units (e.g., "Website Visitors (count)" or "Month of Year")
24+
- Could use more distinctive Bokeh features like CustomJS, band annotations, or
25+
span annotations to highlight peaks

0 commit comments

Comments
 (0)