Skip to content

Commit d08bd6e

Browse files
claude[bot]github-actions[bot]MarkusNeusinger
authored
feat(bokeh): implement histogram-basic (#309)
## Summary Implements `histogram-basic` for **bokeh** library. **Parent Issue:** #206 **Sub-Issue:** #228 **Base Branch:** `plot/histogram-basic` **Attempt:** 3/3 ## Implementation - `plots/bokeh/quad/histogram-basic/default.py` ## Changes 1. Basic histogram implementation using bokeh's `quad` glyph 2. Uses numpy to compute histogram bins (30 bins for good visual distribution) 3. Follows style guide with 4800x2700 px output dimensions ## Dependencies - `selenium>=4.15.0` and `webdriver-manager>=4.0.0` are already in `lib-bokeh` dependencies in `pyproject.toml` (required for `export_png`) ## CI Notes **Important:** The CI workflow needs to be updated to set up Chrome for bokeh PNG export (similar to highcharts). The fix is to update `.github/workflows/ci-plottest.yml`: ```yaml - name: Setup Chrome for Highcharts/Bokeh if: steps.detect_libs.outputs.has_plots == 'true' && (contains(steps.detect_libs.outputs.libraries, 'highcharts') || contains(steps.detect_libs.outputs.libraries, 'bokeh')) uses: browser-actions/setup-chrome@v1 with: chrome-version: stable ``` ## Verified Locally - Implementation tested locally and generates correct plot.png (4800x2700 px) - Code passes ruff format and lint checks --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
1 parent 4ad896b commit d08bd6e

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
histogram-basic: Basic Histogram
3+
Library: bokeh
4+
"""
5+
6+
import numpy as np
7+
from bokeh.io import export_png
8+
from bokeh.plotting import figure
9+
10+
11+
# Data - 500 normally distributed values (mean=100, std=15)
12+
np.random.seed(42)
13+
values = np.random.normal(100, 15, 500)
14+
15+
# Compute histogram bins
16+
hist, edges = np.histogram(values, bins=30)
17+
18+
# Create figure (4800 x 2700 px for high resolution)
19+
p = figure(width=4800, height=2700, title="Basic Histogram", x_axis_label="Value", y_axis_label="Frequency")
20+
21+
# Draw histogram using quad glyph
22+
p.quad(
23+
top=hist,
24+
bottom=0,
25+
left=edges[:-1],
26+
right=edges[1:],
27+
fill_color="#306998",
28+
fill_alpha=0.7,
29+
line_color="white",
30+
line_width=1,
31+
)
32+
33+
# Style title
34+
p.title.text_font_size = "20pt"
35+
p.title.align = "center"
36+
37+
# Style axis labels
38+
p.xaxis.axis_label_text_font_size = "20pt"
39+
p.yaxis.axis_label_text_font_size = "20pt"
40+
p.xaxis.major_label_text_font_size = "16pt"
41+
p.yaxis.major_label_text_font_size = "16pt"
42+
43+
# Style grid - subtle
44+
p.xgrid.grid_line_alpha = 0.3
45+
p.ygrid.grid_line_alpha = 0.3
46+
47+
# Ensure y-axis starts at zero
48+
p.y_range.start = 0
49+
50+
# Save output
51+
export_png(p, filename="plot.png")

0 commit comments

Comments
 (0)