Skip to content

Commit db8b2f7

Browse files
feat(bokeh): implement scatter-basic (#1319)
## Implementation: `scatter-basic` - bokeh Implements the **bokeh** version of `scatter-basic`. **File:** `plots/scatter-basic/implementations/bokeh.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20446832275)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b0e6d73 commit db8b2f7

2 files changed

Lines changed: 47 additions & 29 deletions

File tree

plots/scatter-basic/implementations/bokeh.py

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,48 @@
11
""" pyplots.ai
22
scatter-basic: Basic Scatter Plot
33
Library: bokeh 3.8.1 | Python 3.13.11
4-
Quality: 100/100 | Created: 2025-12-13
4+
Quality: 85/100 | Created: 2025-12-22
55
"""
66

77
import numpy as np
88
from bokeh.io import export_png
9-
from bokeh.models import ColumnDataSource
9+
from bokeh.models import ColumnDataSource, HoverTool
1010
from bokeh.plotting import figure, output_file, save
1111

1212

13-
# Data
13+
# Data - Study hours vs exam scores (realistic scenario)
1414
np.random.seed(42)
15-
x = np.random.randn(100) * 2 + 10
16-
y = x * 0.8 + np.random.randn(100) * 2
15+
study_hours = np.random.uniform(1, 10, 100)
16+
exam_scores = study_hours * 8 + np.random.randn(100) * 5 + 20
17+
exam_scores = np.clip(exam_scores, 0, 100)
1718

1819
# Create ColumnDataSource
19-
source = ColumnDataSource(data={"x": x, "y": y})
20+
source = ColumnDataSource(data={"study_hours": study_hours, "exam_scores": exam_scores})
2021

2122
# Create figure (4800 x 2700 px for 16:9 aspect ratio)
22-
p = figure(
23-
width=4800, height=2700, title="scatter-basic · bokeh · pyplots.ai", x_axis_label="X Value", y_axis_label="Y Value"
24-
)
25-
26-
# Plot scatter points
27-
p.scatter(x="x", y="y", source=source, size=15, color="#306998", alpha=0.7)
28-
29-
# Styling (scaled for 4800x2700 px canvas)
30-
p.title.text_font_size = "28pt"
31-
p.xaxis.axis_label_text_font_size = "22pt"
32-
p.yaxis.axis_label_text_font_size = "22pt"
33-
p.xaxis.major_label_text_font_size = "18pt"
34-
p.yaxis.major_label_text_font_size = "18pt"
35-
p.grid.grid_line_alpha = 0.3
36-
p.grid.grid_line_dash = "dashed"
23+
p = figure(width=4800, height=2700, title="scatter-basic · bokeh · pyplots.ai")
24+
25+
# Set axis labels explicitly (more reliable than figure parameters)
26+
p.xaxis.axis_label = "Study Hours (hrs)"
27+
p.yaxis.axis_label = "Exam Score (%)"
28+
29+
# Plot scatter points (size increased for visibility on large canvas)
30+
p.scatter(x="study_hours", y="exam_scores", source=source, size=50, color="#306998", alpha=0.7)
31+
32+
# Add HoverTool for interactivity (key Bokeh distinctive feature)
33+
hover = HoverTool(tooltips=[("Study Hours", "@study_hours{0.1} hrs"), ("Exam Score", "@exam_scores{0.1}%")])
34+
p.add_tools(hover)
35+
36+
# Styling (scaled for 4800x2700 px canvas - larger sizes for readability)
37+
p.title.text_font_size = "72pt"
38+
p.xaxis.axis_label_text_font_size = "48pt"
39+
p.yaxis.axis_label_text_font_size = "48pt"
40+
p.xaxis.major_label_text_font_size = "36pt"
41+
p.yaxis.major_label_text_font_size = "36pt"
42+
43+
# Grid styling (subtle, per quality criteria VQ-07: alpha 0.2-0.4)
44+
p.grid.grid_line_alpha = 0.35
45+
p.grid.grid_line_width = 2
3746

3847
# Save as PNG
3948
export_png(p, filename="plot.png")
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
library: bokeh
22
specification_id: scatter-basic
3-
created: 2025-12-13 23:13:59+00:00
4-
updated: 2025-12-13 23:13:59+00:00
3+
created: '2025-12-22T23:35:35Z'
4+
updated: '2025-12-23T00:15:21Z'
55
generated_by: claude-opus-4-5-20251101
6-
workflow_run: 20199223493
7-
issue: 611
6+
workflow_run: 20446832275
7+
issue: 0
88
python_version: 3.13.11
99
library_version: 3.8.1
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/bokeh/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/bokeh/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/bokeh/plot.html
13-
quality_score: 100
13+
quality_score: 85
1414
review:
15-
strengths: []
16-
weaknesses: []
17-
improvements: []
15+
strengths:
16+
- Excellent text legibility with well-scaled font sizes for 4800x2700 canvas
17+
- Clean KISS code structure with proper reproducibility (seed=42)
18+
- Realistic educational data scenario (study hours vs exam scores)
19+
- Correct title format and descriptive axis labels with units
20+
- Proper use of ColumnDataSource pattern
21+
weaknesses:
22+
- HoverTool adds no value to static PNG output - Bokeh distinctive features not
23+
visible in rendered image
24+
- Marker size=50 is slightly too large for 100 points, causing visual density issues
25+
in clustered regions
26+
- No legend to identify the data series (minor for single-series plot)

0 commit comments

Comments
 (0)