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
74 changes: 74 additions & 0 deletions plots/histogram-stepwise/implementations/pygal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
""" pyplots.ai
histogram-stepwise: Step Histogram
Library: pygal 3.1.0 | Python 3.13.11
Quality: 91/100 | Created: 2025-12-30
"""

import numpy as np
import pygal
from pygal.style import Style


# Data
np.random.seed(42)
values = np.concatenate([np.random.normal(50, 10, 200), np.random.normal(80, 8, 150)])

# Compute histogram bins
counts, bin_edges = np.histogram(values, bins=25)

# Build step coordinates for pygal.XY
# Step histogram: horizontal segments at count levels, vertical connections
step_data = []
for i in range(len(counts)):
left = bin_edges[i]
right = bin_edges[i + 1]
count = counts[i]
# Horizontal segment for this bin
step_data.append((left, count))
step_data.append((right, count))

# Add baseline at start and end
step_data.insert(0, (bin_edges[0], 0))
step_data.append((bin_edges[-1], 0))

# Custom style for large canvas
custom_style = Style(
background="white",
plot_background="white",
foreground="#333333",
foreground_strong="#333333",
foreground_subtle="#666666",
colors=("#306998",),
title_font_size=48,
label_font_size=36,
major_label_font_size=32,
legend_font_size=32,
value_font_size=28,
stroke_width=4,
opacity=1.0,
opacity_hover=1.0,
)

# Create XY chart for step lines
chart = pygal.XY(
width=4800,
height=2700,
style=custom_style,
title="histogram-stepwise · pygal · pyplots.ai",
x_title="Value",
y_title="Frequency",
show_dots=False,
stroke_style={"width": 4},
fill=False,
show_legend=False,
show_y_guides=True,
show_x_guides=False,
x_label_rotation=0,
)

# Add step line data
chart.add("Distribution", step_data)

# Save outputs
chart.render_to_file("plot.html")
chart.render_to_png("plot.png")
25 changes: 25 additions & 0 deletions plots/histogram-stepwise/metadata/pygal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
library: pygal
specification_id: histogram-stepwise
created: '2025-12-30T11:22:08Z'
updated: '2025-12-30T11:29:13Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20595338040
issue: 0
python_version: 3.13.11
library_version: 3.1.0
preview_url: https://storage.googleapis.com/pyplots-images/plots/histogram-stepwise/pygal/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/histogram-stepwise/pygal/plot_thumb.png
preview_html: https://storage.googleapis.com/pyplots-images/plots/histogram-stepwise/pygal/plot.html
quality_score: 91
review:
strengths:
- Excellent implementation of step histogram using XY chart with carefully constructed
step coordinates
- Clean, readable code with proper KISS structure and reproducible seed
- Bimodal distribution data effectively showcases the plot type ability to reveal
distribution shapes
- Proper title format and clear axis labels
- Good font sizing for the 4800x2700 canvas
weaknesses:
- Axis labels lack units (e.g., Value (units) or Frequency (count))
- Could use more realistic/contextual data scenario instead of abstract values