Skip to content

Commit 4c097fc

Browse files
feat(matplotlib): implement histogram-stacked (#2617)
## Implementation: `histogram-stacked` - matplotlib Implements the **matplotlib** version of `histogram-stacked`. **File:** `plots/histogram-stacked/implementations/matplotlib.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594557552)* --------- 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 a12fc07 commit 4c097fc

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
""" pyplots.ai
2+
histogram-stacked: Stacked Histogram
3+
Library: matplotlib 3.10.8 | Python 3.13.11
4+
Quality: 92/100 | Created: 2025-12-30
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
11+
# Data - Response times (ms) for three different server regions
12+
np.random.seed(42)
13+
14+
# Generate data for three server regions with different distributions
15+
us_east = np.random.normal(loc=45, scale=12, size=200) # Fast region
16+
europe = np.random.normal(loc=65, scale=15, size=180) # Medium region
17+
asia = np.random.normal(loc=80, scale=20, size=150) # Slower region
18+
19+
# Clip to realistic values
20+
us_east = np.clip(us_east, 10, 120)
21+
europe = np.clip(europe, 15, 140)
22+
asia = np.clip(asia, 20, 160)
23+
24+
# Colors - Python Blue first, then Yellow, then complementary
25+
colors = ["#306998", "#FFD43B", "#5BA85B"]
26+
labels = ["US-East", "Europe", "Asia-Pacific"]
27+
28+
# Create plot (4800x2700 px at 300 DPI = 16x9 inches)
29+
fig, ax = plt.subplots(figsize=(16, 9))
30+
31+
# Create stacked histogram
32+
ax.hist(
33+
[us_east, europe, asia],
34+
bins=20,
35+
stacked=True,
36+
color=colors,
37+
label=labels,
38+
edgecolor="white",
39+
linewidth=0.8,
40+
alpha=0.9,
41+
)
42+
43+
# Labels and styling (scaled font sizes for 4800x2700)
44+
ax.set_xlabel("Response Time (ms)", fontsize=20)
45+
ax.set_ylabel("Number of Requests", fontsize=20)
46+
ax.set_title("histogram-stacked · matplotlib · pyplots.ai", fontsize=24)
47+
ax.tick_params(axis="both", labelsize=16)
48+
ax.grid(True, alpha=0.3, linestyle="--", axis="y")
49+
50+
# Legend
51+
ax.legend(fontsize=16, loc="upper right", framealpha=0.9)
52+
53+
plt.tight_layout()
54+
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: matplotlib
2+
specification_id: histogram-stacked
3+
created: '2025-12-30T10:38:07Z'
4+
updated: '2025-12-30T10:45:38Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594557552
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.10.8
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/histogram-stacked/matplotlib/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/histogram-stacked/matplotlib/plot_thumb.png
12+
preview_html: null
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent realistic data scenario with server response times across geographic
17+
regions
18+
- Clean stacking visualization with good color separation using white edge lines
19+
- All three distributions have distinct characteristics (different means, scales,
20+
and sample sizes)
21+
- Perfect title format and axis labeling with units
22+
- Good use of alpha for slight transparency while maintaining visibility
23+
weaknesses:
24+
- No distinctive matplotlib features beyond basic histogram; could use annotations,
25+
custom spine styling, or statistical overlays
26+
- Legend visual separation could be enhanced with a border or better background

0 commit comments

Comments
 (0)