Skip to content

Commit 44cfd47

Browse files
feat(bokeh): implement point-basic (#2586)
## Implementation: `point-basic` - bokeh Implements the **bokeh** version of `point-basic`. **File:** `plots/point-basic/implementations/bokeh.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20593350532)* --------- 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 17fdb60 commit 44cfd47

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
""" pyplots.ai
2+
point-basic: Point Estimate 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, Span, TeeHead, Whisker
10+
from bokeh.plotting import figure
11+
from bokeh.resources import CDN
12+
13+
14+
# Data - Effect sizes for different treatment groups with 95% confidence intervals
15+
np.random.seed(42)
16+
categories = ["Treatment A", "Treatment B", "Treatment C", "Treatment D", "Treatment E", "Control"]
17+
estimates = np.array([2.5, 1.8, 3.2, -0.5, 1.2, 0.0])
18+
# Generate confidence intervals with varying widths
19+
ci_widths = np.array([0.8, 1.2, 0.6, 0.9, 1.5, 0.4])
20+
lower = estimates - ci_widths
21+
upper = estimates + ci_widths
22+
23+
# Create ColumnDataSource
24+
source = ColumnDataSource(data={"categories": categories, "estimates": estimates, "lower": lower, "upper": upper})
25+
26+
# Create figure with categorical y-axis (horizontal orientation for readability)
27+
p = figure(
28+
width=4800,
29+
height=2700,
30+
y_range=categories[::-1], # Reverse order so first category is at top
31+
title="point-basic · bokeh · pyplots.ai",
32+
x_axis_label="Effect Size",
33+
y_axis_label="Treatment Group",
34+
)
35+
36+
# Add reference line at zero (null hypothesis)
37+
zero_line = Span(location=0, dimension="height", line_color="#888888", line_width=3, line_dash="dashed")
38+
p.add_layout(zero_line)
39+
40+
# Add error bars using Whisker with TeeHead caps (horizontal)
41+
whisker = Whisker(
42+
source=source,
43+
base="categories",
44+
lower="lower",
45+
upper="upper",
46+
dimension="width",
47+
line_color="#306998",
48+
line_width=6,
49+
upper_head=TeeHead(size=30, line_color="#306998", line_width=6),
50+
lower_head=TeeHead(size=30, line_color="#306998", line_width=6),
51+
)
52+
p.add_layout(whisker)
53+
54+
# Plot points (estimates) with larger markers for visibility
55+
p.scatter(x="estimates", y="categories", source=source, size=40, color="#306998", fill_color="#FFD43B", line_width=4)
56+
57+
# Styling for large canvas
58+
p.title.text_font_size = "36pt"
59+
p.xaxis.axis_label_text_font_size = "28pt"
60+
p.yaxis.axis_label_text_font_size = "28pt"
61+
p.xaxis.major_label_text_font_size = "22pt"
62+
p.yaxis.major_label_text_font_size = "22pt"
63+
64+
# Grid styling
65+
p.xgrid.grid_line_alpha = 0.3
66+
p.xgrid.grid_line_dash = "dashed"
67+
p.ygrid.grid_line_alpha = 0.3
68+
p.ygrid.grid_line_dash = "dashed"
69+
70+
# Remove toolbar and outline for cleaner look
71+
p.toolbar_location = None
72+
p.outline_line_color = None
73+
74+
# Save as PNG and HTML
75+
export_png(p, filename="plot.png")
76+
save(p, filename="plot.html", resources=CDN, title="point-basic · bokeh · pyplots.ai")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: bokeh
2+
specification_id: point-basic
3+
created: '2025-12-30T09:33:27Z'
4+
updated: '2025-12-30T09:44:17Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20593350532
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/point-basic/bokeh/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/point-basic/bokeh/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/point-basic/bokeh/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent implementation of horizontal point estimate plot with proper orientation
17+
for readability
18+
- Proper use of Bokeh's Whisker annotation with TeeHead caps for error bars
19+
- Clean reference line at zero using Span model
20+
- Appropriate font sizing for the large canvas (36pt title, 28pt labels, 22pt ticks)
21+
- Good visual hierarchy with yellow-filled points outlined in blue
22+
- Realistic treatment effect data with varying confidence interval widths
23+
weaknesses:
24+
- Could benefit from HoverTool to show exact values on mouse-over (Bokeh's key interactive
25+
feature)
26+
- Axis labels lack units (e.g., "Effect Size (Cohen's d)" would be more informative)

0 commit comments

Comments
 (0)