Skip to content

Commit 5b9b438

Browse files
feat(pygal): implement histogram-stepwise (#2657)
## Implementation: `histogram-stepwise` - pygal Implements the **pygal** version of `histogram-stepwise`. **File:** `plots/histogram-stepwise/implementations/pygal.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20595338040)* --------- 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 62b15da commit 5b9b438

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
""" pyplots.ai
2+
histogram-stepwise: Step Histogram
3+
Library: pygal 3.1.0 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pygal
9+
from pygal.style import Style
10+
11+
12+
# Data
13+
np.random.seed(42)
14+
values = np.concatenate([np.random.normal(50, 10, 200), np.random.normal(80, 8, 150)])
15+
16+
# Compute histogram bins
17+
counts, bin_edges = np.histogram(values, bins=25)
18+
19+
# Build step coordinates for pygal.XY
20+
# Step histogram: horizontal segments at count levels, vertical connections
21+
step_data = []
22+
for i in range(len(counts)):
23+
left = bin_edges[i]
24+
right = bin_edges[i + 1]
25+
count = counts[i]
26+
# Horizontal segment for this bin
27+
step_data.append((left, count))
28+
step_data.append((right, count))
29+
30+
# Add baseline at start and end
31+
step_data.insert(0, (bin_edges[0], 0))
32+
step_data.append((bin_edges[-1], 0))
33+
34+
# Custom style for large canvas
35+
custom_style = Style(
36+
background="white",
37+
plot_background="white",
38+
foreground="#333333",
39+
foreground_strong="#333333",
40+
foreground_subtle="#666666",
41+
colors=("#306998",),
42+
title_font_size=48,
43+
label_font_size=36,
44+
major_label_font_size=32,
45+
legend_font_size=32,
46+
value_font_size=28,
47+
stroke_width=4,
48+
opacity=1.0,
49+
opacity_hover=1.0,
50+
)
51+
52+
# Create XY chart for step lines
53+
chart = pygal.XY(
54+
width=4800,
55+
height=2700,
56+
style=custom_style,
57+
title="histogram-stepwise · pygal · pyplots.ai",
58+
x_title="Value",
59+
y_title="Frequency",
60+
show_dots=False,
61+
stroke_style={"width": 4},
62+
fill=False,
63+
show_legend=False,
64+
show_y_guides=True,
65+
show_x_guides=False,
66+
x_label_rotation=0,
67+
)
68+
69+
# Add step line data
70+
chart.add("Distribution", step_data)
71+
72+
# Save outputs
73+
chart.render_to_file("plot.html")
74+
chart.render_to_png("plot.png")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: pygal
2+
specification_id: histogram-stepwise
3+
created: '2025-12-30T11:22:08Z'
4+
updated: '2025-12-30T11:29:13Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20595338040
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/histogram-stepwise/pygal/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/histogram-stepwise/pygal/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/histogram-stepwise/pygal/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent implementation of step histogram using XY chart with carefully constructed
17+
step coordinates
18+
- Clean, readable code with proper KISS structure and reproducible seed
19+
- Bimodal distribution data effectively showcases the plot type ability to reveal
20+
distribution shapes
21+
- Proper title format and clear axis labels
22+
- Good font sizing for the 4800x2700 canvas
23+
weaknesses:
24+
- Axis labels lack units (e.g., Value (units) or Frequency (count))
25+
- Could use more realistic/contextual data scenario instead of abstract values

0 commit comments

Comments
 (0)