Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions plots/bar-error/implementations/pygal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
""" pyplots.ai
bar-error: Bar Chart with Error Bars
Library: pygal 3.1.0 | Python 3.13.11
Quality: 91/100 | Created: 2025-12-27
"""

import pygal
from pygal.style import Style


# Data: Experimental results comparing treatment effectiveness
# Mean values with standard deviations (±1 SD)
categories = ["Control", "Treatment A", "Treatment B", "Treatment C", "Treatment D"]
values = [45.2, 62.8, 78.3, 55.1, 71.5]
errors = [8.5, 12.3, 9.7, 15.2, 11.8]

# Custom style for 4800x2700 canvas
custom_style = Style(
background="white",
plot_background="white",
foreground="#333333",
foreground_strong="#333333",
foreground_subtle="#666666",
colors=("#306998", "#FFD43B", "#4CAF50", "#E91E63", "#9C27B0"),
font_family="DejaVu Sans, Verdana, sans-serif",
title_font_size=72,
label_font_size=48,
major_label_font_size=48,
legend_font_size=48,
value_font_size=36,
value_label_font_size=36,
tooltip_font_size=36,
)

# Create bar chart with error bars (confidence intervals)
chart = pygal.Bar(
width=4800,
height=2700,
style=custom_style,
title="bar-error \u00b7 pygal \u00b7 pyplots.ai",
x_title="Treatment Group",
y_title="Response Value (units)",
show_legend=True,
legend_at_bottom=True,
legend_at_bottom_columns=1,
show_y_guides=True,
show_x_guides=False,
print_values=False,
range=(0, 100),
spacing=40,
margin=100,
margin_bottom=250,
margin_left=200,
margin_top=180,
dots_size=8,
stroke_style={"width": 4},
)

# X-axis labels
chart.x_labels = categories

# Add data with confidence intervals (error bars)
# Each value is a dict with 'value' and 'ci' containing 'low' and 'high'
data_with_errors = []
for val, err in zip(values, errors, strict=True):
data_with_errors.append({"value": val, "ci": {"low": val - err, "high": val + err}})

chart.add("Mean \u00b1 1 SD", data_with_errors)

# Save as PNG and HTML (interactive)
chart.render_to_png("plot.png")
chart.render_to_file("plot.html")
25 changes: 25 additions & 0 deletions plots/bar-error/metadata/pygal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
library: pygal
specification_id: bar-error
created: '2025-12-27T19:22:12Z'
updated: '2025-12-27T19:29:48Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20543283514
issue: 0
python_version: 3.13.11
library_version: 3.1.0
preview_url: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot_thumb.png
preview_html: https://storage.googleapis.com/pyplots-images/plots/bar-error/pygal/plot.html
quality_score: 91
review:
strengths:
- Excellent use of pygal native confidence interval (ci) feature for error bars
with caps
- Clean professional appearance with appropriate font scaling for 4800x2700 canvas
- Well-chosen scientific context (treatment comparison) that matches spec applications
- Proper title format and comprehensive axis labeling with units
- Good use of custom Style for consistent visual appearance
weaknesses:
- Legend placement at bottom-left corner appears disconnected from the chart
- Grid lines could be more subtle (currently dotted but still prominent)
- Only symmetric error bars shown when spec mentions asymmetric as an option