Skip to content

Commit c89bd83

Browse files
feat(bokeh): implement scatter-annotated (#2807)
## Implementation: `scatter-annotated` - bokeh Implements the **bokeh** version of `scatter-annotated`. **File:** `plots/scatter-annotated/implementations/bokeh.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20602453064)* --------- 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 b38dcf4 commit c89bd83

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
""" pyplots.ai
2+
scatter-annotated: Annotated Scatter Plot with Text Labels
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
9+
from bokeh.models import ColumnDataSource, LabelSet
10+
from bokeh.plotting import figure
11+
12+
13+
# Data - Company market performance example
14+
np.random.seed(42)
15+
companies = [
16+
"TechCorp",
17+
"DataSys",
18+
"CloudNet",
19+
"AIVenture",
20+
"NetFlow",
21+
"CodeBase",
22+
"ByteWorks",
23+
"DigiCore",
24+
"InfoTech",
25+
"WebScale",
26+
"AppLogic",
27+
"SoftPeak",
28+
"CyberLink",
29+
"DevOps",
30+
"QuantumBit",
31+
]
32+
33+
# Revenue (billions) and Market Cap (billions)
34+
revenue = np.array([12.5, 8.3, 22.1, 5.7, 15.8, 9.2, 18.4, 6.9, 11.3, 25.6, 7.4, 14.2, 19.8, 4.5, 10.1])
35+
market_cap = np.array([45.2, 28.1, 85.3, 32.5, 52.8, 35.6, 68.9, 25.4, 41.7, 98.2, 22.3, 55.4, 72.1, 18.9, 38.5])
36+
37+
# Create ColumnDataSource
38+
source = ColumnDataSource(data={"x": revenue, "y": market_cap, "labels": companies})
39+
40+
# Create figure
41+
p = figure(
42+
width=4800,
43+
height=2700,
44+
title="scatter-annotated · bokeh · pyplots.ai",
45+
x_axis_label="Revenue (Billions $)",
46+
y_axis_label="Market Cap (Billions $)",
47+
tools="pan,wheel_zoom,box_zoom,reset",
48+
)
49+
50+
# Plot scatter points - larger size for visibility
51+
p.scatter(x="x", y="y", source=source, size=40, color="#306998", alpha=0.7, line_color="#1a3d5c", line_width=3)
52+
53+
# Add text labels with offset - larger font for 4800x2700 canvas
54+
labels = LabelSet(
55+
x="x",
56+
y="y",
57+
text="labels",
58+
source=source,
59+
x_offset=25,
60+
y_offset=15,
61+
text_font_size="24pt",
62+
text_color="#333333",
63+
text_font_style="bold",
64+
)
65+
p.add_layout(labels)
66+
67+
# Style title - large for visibility
68+
p.title.text_font_size = "42pt"
69+
p.title.text_color = "#333333"
70+
p.title.align = "center"
71+
72+
# Style axes labels - large for readability
73+
p.xaxis.axis_label_text_font_size = "32pt"
74+
p.yaxis.axis_label_text_font_size = "32pt"
75+
p.xaxis.axis_label_text_color = "#333333"
76+
p.yaxis.axis_label_text_color = "#333333"
77+
78+
# Style tick labels - larger
79+
p.xaxis.major_label_text_font_size = "24pt"
80+
p.yaxis.major_label_text_font_size = "24pt"
81+
82+
# Style grid
83+
p.grid.grid_line_alpha = 0.3
84+
p.grid.grid_line_dash = [6, 4]
85+
p.grid.grid_line_color = "#888888"
86+
87+
# Background
88+
p.background_fill_color = "#fafafa"
89+
p.border_fill_color = "#ffffff"
90+
91+
# Axis styling
92+
p.axis.axis_line_color = "#555555"
93+
p.axis.axis_line_width = 2
94+
p.axis.major_tick_line_width = 2
95+
p.axis.minor_tick_line_width = 1
96+
97+
# Save
98+
export_png(p, filename="plot.png")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library: bokeh
2+
specification_id: scatter-annotated
3+
created: '2025-12-30T17:48:20Z'
4+
updated: '2025-12-30T17:55:48Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20602453064
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/scatter-annotated/bokeh/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-annotated/bokeh/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-annotated/bokeh/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent text sizing throughout - all elements perfectly legible at 4800x2700
17+
resolution
18+
- Well-chosen realistic business scenario (tech company market performance) with
19+
appropriate data ranges
20+
- Good use of Bokeh's ColumnDataSource and LabelSet for clean data binding
21+
- Proper styling with subtle grid, good color choice, and appropriate marker sizing
22+
for the data density
23+
- Clean KISS code structure with reproducible seed
24+
weaknesses:
25+
- Missing connecting lines/arrows from labels to points as specified in the notes
26+
section of the specification
27+
- Some label pairs are close together (ByteWorks/CyberLink, SoftPeak/NetFlow) -
28+
could benefit from collision avoidance
29+
- Does not leverage Bokeh's distinctive hover tooltip feature which would enhance
30+
the visualization

0 commit comments

Comments
 (0)