Skip to content

Commit bfa332f

Browse files
feat(bokeh): implement stem-basic (#5632)
## Implementation: `stem-basic` - python/bokeh Implements the **python/bokeh** version of `stem-basic`. **File:** `plots/stem-basic/implementations/python/bokeh.py` **Parent Issue:** #972 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/25172053900)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
1 parent 44a1857 commit bfa332f

2 files changed

Lines changed: 202 additions & 142 deletions

File tree

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
stem-basic: Basic Stem Plot
3-
Library: bokeh 3.8.1 | Python 3.13.11
4-
Quality: 91/100 | Created: 2025-12-23
3+
Library: bokeh 3.9.0 | Python 3.13.13
4+
Quality: 84/100 | Updated: 2026-04-30
55
"""
66

7+
import os
8+
import sys
9+
10+
11+
sys.path = [p for p in sys.path if not p.endswith("/python")]
12+
713
import numpy as np
814
from bokeh.io import export_png, output_file, save
915
from bokeh.models import ColumnDataSource
1016
from bokeh.plotting import figure
1117

1218

19+
# Theme tokens
20+
THEME = os.getenv("ANYPLOT_THEME", "light")
21+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
22+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
23+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
24+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
25+
BRAND = "#009E73"
26+
1327
# Data - Discrete signal samples (damped oscillation)
1428
np.random.seed(42)
1529
n_points = 30
1630
x = np.arange(n_points)
1731
y = np.exp(-0.1 * x) * np.sin(0.5 * x) * 2 + np.random.randn(n_points) * 0.1
1832

19-
# Baseline for stems
2033
baseline = 0
2134

2235
# Create data sources
@@ -27,39 +40,48 @@
2740
p = figure(
2841
width=4800,
2942
height=2700,
30-
title="stem-basic · bokeh · pyplots.ai",
43+
title="stem-basic · bokeh · anyplot.ai",
3144
x_axis_label="Sample Index",
3245
y_axis_label="Amplitude",
3346
)
3447

3548
# Draw stems (vertical lines from baseline to data points)
36-
p.segment(x0="x0", y0="y0", x1="x1", y1="y1", source=stem_source, line_width=4, color="#306998", alpha=0.8)
49+
p.segment(x0="x0", y0="y0", x1="x1", y1="y1", source=stem_source, line_width=4, color=BRAND, alpha=0.85)
3750

3851
# Draw markers at data points
39-
p.scatter(x="x", y="y", source=source, size=25, color="#306998", alpha=0.9)
52+
p.scatter(x="x", y="y", source=source, size=25, color=BRAND, alpha=1.0)
4053

4154
# Draw baseline
42-
p.line(
43-
x=[x.min() - 0.5, x.max() + 0.5],
44-
y=[baseline, baseline],
45-
line_width=3,
46-
line_dash="dashed",
47-
color="#999999",
48-
alpha=0.6,
49-
)
55+
p.line(x=[x.min() - 0.5, x.max() + 0.5], y=[baseline, baseline], line_width=3, color=INK_SOFT, alpha=0.6)
5056

51-
# Styling for 4800x2700
57+
# Sizing
5258
p.title.text_font_size = "36pt"
5359
p.xaxis.axis_label_text_font_size = "28pt"
5460
p.yaxis.axis_label_text_font_size = "28pt"
5561
p.xaxis.major_label_text_font_size = "22pt"
5662
p.yaxis.major_label_text_font_size = "22pt"
5763

58-
# Grid styling
59-
p.grid.grid_line_alpha = 0.3
60-
p.grid.grid_line_dash = "dashed"
64+
# Theme-adaptive chrome
65+
p.background_fill_color = PAGE_BG
66+
p.border_fill_color = PAGE_BG
67+
p.outline_line_color = INK_SOFT
68+
69+
p.title.text_color = INK
70+
p.xaxis.axis_label_text_color = INK
71+
p.yaxis.axis_label_text_color = INK
72+
p.xaxis.major_label_text_color = INK_SOFT
73+
p.yaxis.major_label_text_color = INK_SOFT
74+
p.xaxis.axis_line_color = INK_SOFT
75+
p.yaxis.axis_line_color = INK_SOFT
76+
p.xaxis.major_tick_line_color = INK_SOFT
77+
p.yaxis.major_tick_line_color = INK_SOFT
78+
79+
p.xgrid.grid_line_color = INK
80+
p.ygrid.grid_line_color = INK
81+
p.xgrid.grid_line_alpha = 0.10
82+
p.ygrid.grid_line_alpha = 0.10
6183

6284
# Save outputs
63-
export_png(p, filename="plot.png")
64-
output_file("plot.html")
85+
export_png(p, filename=f"plot-{THEME}.png")
86+
output_file(f"plot-{THEME}.html")
6587
save(p)

0 commit comments

Comments
 (0)