Skip to content

Commit 53e4676

Browse files
feat(letsplot): implement histogram-cumulative (#2596)
## Implementation: `histogram-cumulative` - letsplot Implements the **letsplot** version of `histogram-cumulative`. **File:** `plots/histogram-cumulative/implementations/letsplot.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20593353906)* --------- 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 5d97c0a commit 53e4676

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
""" pyplots.ai
2+
histogram-cumulative: Cumulative Histogram
3+
Library: letsplot 4.8.2 | Python 3.13.11
4+
Quality: 99/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pandas as pd
9+
from lets_plot import *
10+
11+
12+
LetsPlot.setup_html()
13+
14+
# Data - Response times in milliseconds (realistic API monitoring scenario)
15+
np.random.seed(42)
16+
response_times = np.concatenate(
17+
[
18+
np.random.exponential(scale=50, size=400), # Normal requests
19+
np.random.exponential(scale=150, size=80), # Slower requests
20+
np.random.uniform(300, 500, size=20), # Occasional slow outliers
21+
]
22+
)
23+
24+
# Compute cumulative histogram data
25+
n_bins = 25
26+
counts, bin_edges = np.histogram(response_times, bins=n_bins)
27+
cumulative_counts = np.cumsum(counts)
28+
29+
df = pd.DataFrame({"xmin": bin_edges[:-1], "xmax": bin_edges[1:], "ymin": 0, "ymax": cumulative_counts})
30+
31+
# Plot - Cumulative histogram using geom_rect for precise bin widths
32+
plot = (
33+
ggplot(df)
34+
+ geom_rect(
35+
aes(xmin="xmin", xmax="xmax", ymin="ymin", ymax="ymax"), fill="#306998", color="#1e4a6e", alpha=0.85, size=0.5
36+
)
37+
+ labs(x="Response Time (ms)", y="Cumulative Count", title="histogram-cumulative · letsplot · pyplots.ai")
38+
+ scale_x_continuous(expand=[0.02, 0])
39+
+ scale_y_continuous(expand=[0, 0, 0.05, 0])
40+
+ theme_minimal()
41+
+ theme(
42+
plot_title=element_text(size=24, face="bold"),
43+
axis_title=element_text(size=20),
44+
axis_text=element_text(size=16),
45+
panel_grid_major=element_line(color="#cccccc", size=0.3),
46+
panel_grid_minor=element_blank(),
47+
)
48+
+ ggsize(1600, 900)
49+
)
50+
51+
# Save as PNG and HTML
52+
ggsave(plot, "plot.png", scale=3)
53+
ggsave(plot, "plot.html")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
library: letsplot
2+
specification_id: histogram-cumulative
3+
created: '2025-12-30T09:37:49Z'
4+
updated: '2025-12-30T09:47:30Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20593353906
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 4.8.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/histogram-cumulative/letsplot/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/histogram-cumulative/letsplot/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/histogram-cumulative/letsplot/plot.html
13+
quality_score: 99
14+
review:
15+
strengths:
16+
- Excellent visual quality with proper text sizing and canvas utilization
17+
- Correct implementation of cumulative histogram using geom_rect for precise bin
18+
control
19+
- Realistic API response time scenario with appropriate data distribution
20+
- Clean KISS code structure with proper reproducibility seed
21+
- Proper title format following spec guidelines
22+
weaknesses:
23+
- Could use geom_histogram with cumulative parameter if available, though geom_rect
24+
approach is valid

0 commit comments

Comments
 (0)