Skip to content

Commit 4f2a101

Browse files
feat(pygal): implement bar-error (#2402)
## Implementation: `bar-error` - pygal Implements the **pygal** version of `bar-error`. **File:** `plots/bar-error/implementations/pygal.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20543283514)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 3c73c7d commit 4f2a101

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
""" pyplots.ai
2+
bar-error: Bar Chart with Error Bars
3+
Library: pygal 3.1.0 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-27
5+
"""
6+
7+
import pygal
8+
from pygal.style import Style
9+
10+
11+
# Data: Experimental results comparing treatment effectiveness
12+
# Mean values with standard deviations (±1 SD)
13+
categories = ["Control", "Treatment A", "Treatment B", "Treatment C", "Treatment D"]
14+
values = [45.2, 62.8, 78.3, 55.1, 71.5]
15+
errors = [8.5, 12.3, 9.7, 15.2, 11.8]
16+
17+
# Custom style for 4800x2700 canvas
18+
custom_style = Style(
19+
background="white",
20+
plot_background="white",
21+
foreground="#333333",
22+
foreground_strong="#333333",
23+
foreground_subtle="#666666",
24+
colors=("#306998", "#FFD43B", "#4CAF50", "#E91E63", "#9C27B0"),
25+
font_family="DejaVu Sans, Verdana, sans-serif",
26+
title_font_size=72,
27+
label_font_size=48,
28+
major_label_font_size=48,
29+
legend_font_size=48,
30+
value_font_size=36,
31+
value_label_font_size=36,
32+
tooltip_font_size=36,
33+
)
34+
35+
# Create bar chart with error bars (confidence intervals)
36+
chart = pygal.Bar(
37+
width=4800,
38+
height=2700,
39+
style=custom_style,
40+
title="bar-error \u00b7 pygal \u00b7 pyplots.ai",
41+
x_title="Treatment Group",
42+
y_title="Response Value (units)",
43+
show_legend=True,
44+
legend_at_bottom=True,
45+
legend_at_bottom_columns=1,
46+
show_y_guides=True,
47+
show_x_guides=False,
48+
print_values=False,
49+
range=(0, 100),
50+
spacing=40,
51+
margin=100,
52+
margin_bottom=250,
53+
margin_left=200,
54+
margin_top=180,
55+
dots_size=8,
56+
stroke_style={"width": 4},
57+
)
58+
59+
# X-axis labels
60+
chart.x_labels = categories
61+
62+
# Add data with confidence intervals (error bars)
63+
# Each value is a dict with 'value' and 'ci' containing 'low' and 'high'
64+
data_with_errors = []
65+
for val, err in zip(values, errors, strict=True):
66+
data_with_errors.append({"value": val, "ci": {"low": val - err, "high": val + err}})
67+
68+
chart.add("Mean \u00b1 1 SD", data_with_errors)
69+
70+
# Save as PNG and HTML (interactive)
71+
chart.render_to_png("plot.png")
72+
chart.render_to_file("plot.html")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: pygal
2+
specification_id: bar-error
3+
created: '2025-12-27T19:22:12Z'
4+
updated: '2025-12-27T19:29:48Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20543283514
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.1.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent use of pygal native confidence interval (ci) feature for error bars
17+
with caps
18+
- Clean professional appearance with appropriate font scaling for 4800x2700 canvas
19+
- Well-chosen scientific context (treatment comparison) that matches spec applications
20+
- Proper title format and comprehensive axis labeling with units
21+
- Good use of custom Style for consistent visual appearance
22+
weaknesses:
23+
- Legend placement at bottom-left corner appears disconnected from the chart
24+
- Grid lines could be more subtle (currently dotted but still prominent)
25+
- Only symmetric error bars shown when spec mentions asymmetric as an option

0 commit comments

Comments
 (0)