Skip to content

Commit 5fd49fe

Browse files
feat(plotly): implement point-basic (#2574)
## Implementation: `point-basic` - plotly Implements the **plotly** version of `point-basic`. **File:** `plots/point-basic/implementations/plotly.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20593348770)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d9c81fa commit 5fd49fe

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
""" pyplots.ai
2+
point-basic: Point Estimate Plot
3+
Library: plotly 6.5.0 | Python 3.13.11
4+
Quality: 92/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import plotly.graph_objects as go
9+
10+
11+
# Data - Treatment effects for different interventions
12+
np.random.seed(42)
13+
categories = ["Control", "Treatment A", "Treatment B", "Treatment C", "Treatment D", "Treatment E"]
14+
15+
# Generate realistic point estimates with varying confidence intervals
16+
estimates = [0.0, 2.3, 3.8, 1.5, 4.2, 2.9]
17+
# CI widths vary by sample size/variance
18+
ci_widths = [0.8, 1.2, 0.9, 1.5, 1.1, 1.3]
19+
lower = [e - w for e, w in zip(estimates, ci_widths, strict=False)]
20+
upper = [e + w for e, w in zip(estimates, ci_widths, strict=False)]
21+
22+
# Create figure
23+
fig = go.Figure()
24+
25+
# Add error bars (horizontal orientation)
26+
fig.add_trace(
27+
go.Scatter(
28+
x=estimates,
29+
y=categories,
30+
mode="markers",
31+
marker={"size": 18, "color": "#306998", "symbol": "circle"},
32+
error_x={
33+
"type": "data",
34+
"symmetric": False,
35+
"array": [u - e for e, u in zip(estimates, upper, strict=False)],
36+
"arrayminus": [e - low for e, low in zip(estimates, lower, strict=False)],
37+
"color": "#306998",
38+
"thickness": 3,
39+
"width": 10,
40+
},
41+
name="Estimate ± 95% CI",
42+
showlegend=True,
43+
)
44+
)
45+
46+
# Add reference line at zero (null hypothesis)
47+
fig.add_vline(
48+
x=0,
49+
line={"color": "#FFD43B", "width": 3, "dash": "dash"},
50+
annotation_text="Null",
51+
annotation_position="top",
52+
annotation_font={"size": 18, "color": "#FFD43B"},
53+
)
54+
55+
# Layout
56+
fig.update_layout(
57+
title={"text": "point-basic · plotly · pyplots.ai", "font": {"size": 32}, "x": 0.5, "xanchor": "center"},
58+
xaxis={
59+
"title": {"text": "Effect Size (units)", "font": {"size": 24}},
60+
"tickfont": {"size": 18},
61+
"zeroline": False,
62+
"gridcolor": "rgba(0,0,0,0.1)",
63+
"gridwidth": 1,
64+
},
65+
yaxis={
66+
"title": {"text": "Treatment Group", "font": {"size": 24}},
67+
"tickfont": {"size": 20},
68+
"gridcolor": "rgba(0,0,0,0.1)",
69+
"gridwidth": 1,
70+
},
71+
template="plotly_white",
72+
legend={
73+
"font": {"size": 18},
74+
"x": 0.98,
75+
"y": 0.02,
76+
"xanchor": "right",
77+
"yanchor": "bottom",
78+
"bgcolor": "rgba(255,255,255,0.8)",
79+
},
80+
margin={"l": 150, "r": 80, "t": 100, "b": 80},
81+
)
82+
83+
# Save as PNG and HTML
84+
fig.write_image("plot.png", width=1600, height=900, scale=3)
85+
fig.write_html("plot.html", include_plotlyjs="cdn")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library: plotly
2+
specification_id: point-basic
3+
created: '2025-12-30T09:31:42Z'
4+
updated: '2025-12-30T09:42:21Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20593348770
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 6.5.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/point-basic/plotly/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/point-basic/plotly/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/point-basic/plotly/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent horizontal orientation matching spec recommendation for readability
17+
- Clear reference line at null hypothesis with annotation
18+
- Well-sized markers (18) and error bars with visible caps (width=10)
19+
- Proper use of asymmetric error bars calculated from CI bounds
20+
- Clean clinical trial context that is realistic and neutral
21+
- Good font sizing hierarchy (title 32, labels 24, ticks 18-20)
22+
weaknesses:
23+
- Legend positioned in bottom-right could overlap with data; top-right or outside
24+
placement preferred
25+
- All treatment effects are positive; including one negative effect would better
26+
demonstrate full capability
27+
- Grid opacity at 0.1 is very subtle; 0.2-0.3 would improve readability

0 commit comments

Comments
 (0)