Skip to content

Commit 69307ac

Browse files
feat(letsplot): implement point-basic (#6386)
## Implementation: `point-basic` - python/letsplot Implements the **python/letsplot** version of `point-basic`. **File:** `plots/point-basic/implementations/python/letsplot.py` **Parent Issue:** #2551 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/25685727391)* --------- 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 63277b9 commit 69307ac

2 files changed

Lines changed: 182 additions & 138 deletions

File tree

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
point-basic: Point Estimate Plot
3-
Library: letsplot 4.8.2 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-30
3+
Library: letsplot 4.9.0 | Python 3.13.13
4+
Quality: 89/100 | Updated: 2026-05-11
55
"""
66

7+
import os
8+
79
import numpy as np
810
import pandas as pd
911
from lets_plot import *
1012

1113

1214
LetsPlot.setup_html()
1315

16+
# Theme tokens
17+
THEME = os.getenv("ANYPLOT_THEME", "light")
18+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
19+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
20+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
21+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
22+
RULE = "rgba(26,26,23,0.10)" if THEME == "light" else "rgba(240,239,232,0.10)"
23+
24+
BRAND = "#009E73"
25+
1426
# Data - Research study results with confidence intervals
1527
np.random.seed(42)
1628
categories = ["Treatment A", "Treatment B", "Treatment C", "Control", "Placebo"]
1729
estimates = [4.2, 5.8, 3.1, 2.5, 1.8]
18-
# Generate realistic confidence intervals (narrower for larger effects)
1930
ci_width = [0.9, 1.1, 0.7, 0.8, 0.6]
20-
lower = [e - w for e, w in zip(estimates, ci_width)]
21-
upper = [e + w for e, w in zip(estimates, ci_width)]
31+
lower = [e - w for e, w in zip(estimates, ci_width, strict=False)]
32+
upper = [e + w for e, w in zip(estimates, ci_width, strict=False)]
2233

2334
df = pd.DataFrame({"group": categories, "estimate": estimates, "lower": lower, "upper": upper})
2435

2536
# Plot - Horizontal point estimate plot with confidence intervals
2637
plot = (
2738
ggplot(df, aes(x="group", y="estimate", ymin="lower", ymax="upper"))
28-
+ geom_pointrange(color="#306998", size=1.5, linewidth=1.5)
29-
+ geom_hline(yintercept=0, linetype="dashed", color="#666666", size=0.8, alpha=0.7)
30-
+ labs(y="Effect Size (95% CI)", x="Treatment Group", title="point-basic · lets-plot · pyplots.ai")
39+
+ geom_pointrange(color=BRAND, size=1.5, linewidth=1.5)
40+
+ geom_hline(yintercept=0, linetype="dashed", color=INK_SOFT, size=0.8, alpha=0.5)
41+
+ labs(y="Effect Size (95% CI)", x="Treatment Group", title="point-basic · letsplot · anyplot.ai")
3142
+ coord_flip()
32-
+ theme_minimal()
3343
+ theme(
34-
plot_title=element_text(size=24, face="bold"),
35-
axis_title=element_text(size=20),
36-
axis_text=element_text(size=16),
37-
panel_grid_major_x=element_blank(),
44+
plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
45+
panel_background=element_rect(fill=PAGE_BG),
46+
panel_grid_major_x=element_line(color=RULE, size=0.3),
3847
panel_grid_minor=element_blank(),
48+
panel_grid_major_y=element_blank(),
49+
axis_title=element_text(size=20, color=INK),
50+
axis_text=element_text(size=16, color=INK_SOFT),
51+
axis_line=element_line(color=INK_SOFT, size=0.5),
52+
plot_title=element_text(size=24, color=INK),
3953
)
4054
+ ggsize(1600, 900)
4155
)
4256

4357
# Save
44-
ggsave(plot, "plot.png", path=".", scale=3)
45-
46-
# Save interactive HTML
47-
ggsave(plot, "plot.html", path=".")
58+
ggsave(plot, f"plot-{THEME}.png", path=".", scale=3)
59+
ggsave(plot, f"plot-{THEME}.html", path=".")

0 commit comments

Comments
 (0)