Skip to content

Commit 7013281

Browse files
feat(letsplot): implement errorbar-basic (#9522)
## Implementation: `errorbar-basic` - python/letsplot Implements the **python/letsplot** version of `errorbar-basic`. **File:** `plots/errorbar-basic/implementations/python/letsplot.py` **Parent Issue:** #973 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/28473740576)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 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 fde0a9c commit 7013281

2 files changed

Lines changed: 115 additions & 88 deletions

File tree

plots/errorbar-basic/implementations/python/letsplot.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" anyplot.ai
22
errorbar-basic: Basic Error Bar Plot
3-
Library: letsplot 4.9.0 | Python 3.14.4
4-
Quality: 91/100 | Updated: 2026-04-25
3+
Library: letsplot 4.11.0 | Python 3.13.14
4+
Quality: 89/100 | Updated: 2026-06-30
55
"""
66

77
import os
@@ -32,11 +32,13 @@
3232
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
3333
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
3434
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
35+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
36+
RULE = "#1A1A1726" if THEME == "light" else "#F0EFE826" # 15% opacity — subtle grid
3537

36-
BRAND = "#009E73" # Okabe-Ito position 1
37-
FOCAL = "#C475FD" # Okabe-Ito position 2 — emphasises group with largest spread
38+
BRAND = "#009E73" # Imprint palette position 1
39+
FOCAL = "#C475FD" # Imprint palette position 2 — highlights group with largest spread
3840

39-
# Data — experimental measurements with uncertainty
41+
# Data — clinical measurements comparing control vs treatment groups
4042
data = pd.DataFrame(
4143
{
4244
"experiment": ["Control", "Treatment A", "Treatment B", "Treatment C", "Treatment D"],
@@ -47,24 +49,29 @@
4749
data["ymin"] = data["mean_value"] - data["error"]
4850
data["ymax"] = data["mean_value"] + data["error"]
4951

50-
# Highlight the group with the largest error spread to give the chart a focal point
5152
focal_idx = data["error"].idxmax()
5253
data["highlight"] = ["focal" if i == focal_idx else "base" for i in data.index]
5354

5455
color_map = {"base": BRAND, "focal": FOCAL}
5556

57+
title = "errorbar-basic · python · letsplot · anyplot.ai"
58+
subtitle = (
59+
"Treatment D (highlighted) has the widest error margin (±7.1 mg/dL), indicating higher measurement variability"
60+
)
61+
5662
anyplot_theme = theme(
5763
plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
5864
panel_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
5965
panel_border=element_blank(),
6066
panel_grid_major_x=element_blank(),
6167
panel_grid_minor=element_blank(),
62-
panel_grid_major_y=element_line(color=INK_SOFT, size=0.3),
68+
panel_grid_major_y=element_line(color=RULE, size=0.3),
6369
axis_line=element_line(color=INK_SOFT),
6470
axis_ticks=element_line(color=INK_SOFT),
65-
axis_title=element_text(color=INK, size=20),
66-
axis_text=element_text(color=INK_SOFT, size=16),
67-
plot_title=element_text(color=INK, size=24),
71+
axis_title=element_text(color=INK, size=12),
72+
axis_text=element_text(color=INK_SOFT, size=10),
73+
plot_title=element_text(color=INK, size=16),
74+
plot_subtitle=element_text(color=INK_SOFT, size=11),
6875
legend_position="none",
6976
)
7077

@@ -73,14 +80,14 @@
7380
+ geom_errorbar(aes(ymin="ymin", ymax="ymax"), width=0.3, size=1.5)
7481
+ geom_point(size=6)
7582
+ scale_color_manual(values=color_map)
76-
+ labs(x="Experimental Group", y="Measured Value (mg/dL)", title="errorbar-basic · letsplot · anyplot.ai")
83+
+ labs(x="Experimental Group", y="Measured Value (mg/dL)", title=title, subtitle=subtitle)
7784
+ theme_minimal()
7885
+ anyplot_theme
79-
+ ggsize(1600, 900)
86+
+ ggsize(800, 450)
8087
)
8188

82-
# PNG (scale 3x for 4800 x 2700 px)
83-
ggsave(plot, f"plot-{THEME}.png", scale=3, path=".")
89+
# PNG (scale=4 → 3200 × 1800 px)
90+
ggsave(plot, f"plot-{THEME}.png", scale=4, path=".")
8491

8592
# HTML (interactive)
8693
ggsave(plot, f"plot-{THEME}.html", path=".")

0 commit comments

Comments
 (0)