feat: add histogram-basic implementation (9 libraries)#512
feat: add histogram-basic implementation (9 libraries)#512MarkusNeusinger merged 17 commits intomainfrom
Conversation
## Summary Implements `histogram-basic` for **seaborn** library. **Parent Issue:** #204 **Sub-Issue:** #217 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/seaborn/histplot/histogram-basic/default.py` ## Changes - Simplified implementation to follow KISS pattern (no functions/classes) - Uses direct script flow as per `prompts/plot-generator.md` - Applied project color palette (#306998 Python Blue) - Set proper font sizes per style guide (20pt labels, 16pt ticks) - Uses seaborn's `histplot` with 30 bins for normal distribution data Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **matplotlib** library. **Parent Issue:** #204 **Sub-Issue:** #212 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/matplotlib/hist/histogram-basic/default.py` ## Details - Uses `ax.hist()` with 30 bins for smooth distribution visualization - Follows default style guide: 16:9 aspect ratio (figsize 16x9), Python Blue (#306998) - White edge on bars for visual separation - Proper font sizes: title/axis labels 20pt, tick labels 16pt - Y-axis grid for easier frequency reading Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **altair** library. **Parent Issue:** #204 **Sub-Issue:** #236 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/altair/bar/histogram-basic/default.py` ## Details - Uses `mark_bar()` with binning for histogram visualization - Follows the Python Blue color (#306998) from the style guide - Outputs at 4800×2700 px (1600×900 with scale_factor=3.0) - Proper axis labels and title Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **letsplot** library. **Parent Issue:** #204 **Sub-Issue:** #264 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/letsplot/histogram/histogram-basic/default.py` ## Details - Uses lets-plot's `geom_histogram()` with 30 bins - Follows Python Blue color palette (#306998) from style guide - Output: 4800 x 2700 px PNG (1600x900 base with scale=3) - Clean KISS-style implementation without functions/classes Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **plotly** library. **Parent Issue:** #204 **Sub-Issue:** #223 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/plotly/histogram/histogram-basic/default.py` Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **pygal** library. **Parent Issue:** #204 **Sub-Issue:** #252 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/pygal/histogram/histogram-basic/default.py` ## Details - Uses `pygal.Histogram()` chart type with proper bin format `(height, start, end)` - Uses numpy to calculate histogram bins from the normal distribution data - Follows the default style guide: 4800×2700px, Python Blue (#306998) - KISS implementation with no functions/classes per project guidelines Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **plotnine** library. **Parent Issue:** #204 **Sub-Issue:** #245 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/plotnine/histogram/histogram-basic/default.py` ## Details - Uses `geom_histogram` with 30 bins for optimal distribution visualization - Python Blue (#306998) fill color following style guide - White bin edges for clear separation - 4800×2700px output at 300 DPI (16:9 aspect ratio) - Minimal theme with appropriate typography sizes (title 20pt, axis labels 20pt, tick labels 16pt) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **plotly** library. **Parent Issue:** #204 **Sub-Issue:** #331 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/plotly/histogram/histogram-basic/default.py` ## Changes - Centered title for better visual appearance as per quality criteria (VQ-008) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **highcharts** library. **Parent Issue:** #204 **Sub-Issue:** #258 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/highcharts/histogram/histogram-basic/default.py` ## Details - Uses ColumnSeries with numpy.histogram to compute bins and frequencies - 4800×2700px output dimensions (16:9) - Python Blue (#306998) color scheme - Rotated axis labels (315°) for readability - X-axis: Value ranges, Y-axis: Frequency - 30 bins for the distribution Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **plotly** library. **Parent Issue:** #206 **Sub-Issue:** #398 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/plotly/histogram/histogram-basic/default.py` ## Features - Basic histogram showing frequency distribution of 500 normally distributed data points - Uses Python Blue (#306998) color with 0.85 opacity - Scaled fonts for 4800x2700 resolution (title: 40pt, labels: 40pt, ticks: 32pt) - Added hover template for interactivity - Outputs to plot.png at 4800x2700 pixels (via scale=3 on 1600x900) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **seaborn** library. **Parent Issue:** #206 **Sub-Issue:** #327 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/seaborn/histplot/histogram-basic/default.py` ## Details - Uses `sns.histplot()` for creating the histogram - Python Blue (#306998) color with white edgecolor for visual clarity - 30 bins for good data distribution visualization - Proper axis labels (Value, Frequency) and title - Font sizes per style guide (20pt for labels/title, 16pt for ticks) - Subtle grid for readability - Output: 4766 x 2670 px PNG (approximately 16:9 aspect ratio) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **plotly** library. **Parent Issue:** #206 **Sub-Issue:** #426 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/plotly/histogram/histogram-basic/default.py` ## Features - Basic histogram visualization using `go.Histogram` - Sample data: 500 values from normal distribution (mean=100, std=15) - Python Blue color palette (#306998) with white bar outlines - Proper typography for 4800x2700 output (40pt titles, 32pt labels) - Clean `plotly_white` template with subtle grid styling - 5% bar gap for visual clarity Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **matplotlib** library. **Parent Issue:** #206 **Sub-Issue:** #323 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/matplotlib/hist/histogram-basic/default.py` ## Changes - Uses pandas DataFrame structure as specified in the spec - Follows the style guide: Python Blue (#306998), 16x9 aspect ratio - Font sizes: 20pt for labels/title, 16pt for tick labels - Y-axis grid with 0.3 alpha for readability - Simple sequential code (no functions) per plot-generator rules Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary Implements `histogram-basic` for **bokeh** library. **Parent Issue:** #206 **Sub-Issue:** #228 **Base Branch:** `plot/histogram-basic` **Attempt:** 3/3 ## Implementation - `plots/bokeh/quad/histogram-basic/default.py` ## Changes 1. Basic histogram implementation using bokeh's `quad` glyph 2. Uses numpy to compute histogram bins (30 bins for good visual distribution) 3. Follows style guide with 4800x2700 px output dimensions ## Dependencies - `selenium>=4.15.0` and `webdriver-manager>=4.0.0` are already in `lib-bokeh` dependencies in `pyproject.toml` (required for `export_png`) ## CI Notes **Important:** The CI workflow needs to be updated to set up Chrome for bokeh PNG export (similar to highcharts). The fix is to update `.github/workflows/ci-plottest.yml`: ```yaml - name: Setup Chrome for Highcharts/Bokeh if: steps.detect_libs.outputs.has_plots == 'true' && (contains(steps.detect_libs.outputs.libraries, 'highcharts') || contains(steps.detect_libs.outputs.libraries, 'bokeh')) uses: browser-actions/setup-chrome@v1 with: chrome-version: stable ``` ## Verified Locally - Implementation tested locally and generates correct plot.png (4800x2700 px) - Code passes ruff format and lint checks --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
## Summary Implements `histogram-basic` for **matplotlib** library. **Parent Issue:** #206 **Sub-Issue:** #483 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/matplotlib/hist/histogram-basic/default.py` ## Details - Uses `ax.hist()` with 30 bins for distribution visualization - Follows style guide: 4800 x 2700 px image size - Uses Python Blue (#306998) as the primary color - Includes proper axis labels, title, and subtle y-axis grid - Data: 500 normally distributed values (mean=100, std=15) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
## Summary Implements `histogram-basic` for **matplotlib** library. **Parent Issue:** #206 **Sub-Issue:** #490 **Base Branch:** `plot/histogram-basic` **Attempt:** 1/3 ## Implementation - `plots/matplotlib/hist/histogram-basic/default.py` ## Details - Uses `ax.hist()` with 30 bins for distribution visualization - Python Blue color (#306998) with white edge lines for visual clarity - Proper axis labels (Value, Frequency) and title with 20pt font size - Y-axis grid lines (alpha=0.3) for readability - Output: ~4800x2700 px image at 300 DPI with tight bounding box Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds the histogram-basic plot implementation across all 9 supported libraries, following the spec in specs/histogram-basic.md. The implementations generate histograms showing the frequency distribution of 500 normally distributed values (mean=100, std=15) across 30 bins.
Key changes:
- Converts the seaborn implementation from the legacy
create_plot()function pattern to the new simple script pattern - Adds new implementations for 8 libraries (matplotlib, plotly, bokeh, altair, plotnine, pygal, highcharts, letsplot)
- All implementations follow the style guide using Python Blue (#306998) color and 4800×2700px output dimensions
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plots/seaborn/histplot/histogram-basic/default.py | Refactored from function-based to simple script pattern; matches new project standards |
| plots/matplotlib/hist/histogram-basic/default.py | New matplotlib implementation using ax.hist() with 30 bins |
| plots/plotly/histogram/histogram-basic/default.py | New plotly implementation using go.Histogram; missing explicit bin count |
| plots/bokeh/quad/histogram-basic/default.py | New bokeh implementation using quad glyphs with pre-calculated bins |
| plots/altair/bar/histogram-basic/default.py | New altair implementation using declarative histogram with maxbins=30 |
| plots/plotnine/histogram/histogram-basic/default.py | New plotnine implementation using ggplot2-style syntax with 30 bins |
| plots/pygal/histogram/histogram-basic/default.py | New pygal implementation; uses 20 bins instead of 30 (inconsistent with spec) |
| plots/highcharts/histogram/histogram-basic/default.py | New highcharts implementation with custom styling and Selenium rendering |
| plots/letsplot/histogram/histogram-basic/default.py | New letsplot implementation using ggplot2 grammar with 30 bins |
|
|
||
| # Create figure | ||
| fig = go.Figure() | ||
| fig.add_trace(go.Histogram(x=values, marker={"color": "#306998", "line": {"color": "white", "width": 1}}, opacity=0.85)) |
There was a problem hiding this comment.
The histogram should specify the number of bins to match the spec and other library implementations. All other implementations use 30 bins explicitly. Add nbins=30 parameter to the go.Histogram constructor.
Suggested fix:
fig.add_trace(go.Histogram(x=values, nbins=30, marker={"color": "#306998", "line": {"color": "white", "width": 1}}, opacity=0.85))| fig.add_trace(go.Histogram(x=values, marker={"color": "#306998", "line": {"color": "white", "width": 1}}, opacity=0.85)) | |
| fig.add_trace(go.Histogram(x=values, nbins=30, marker={"color": "#306998", "line": {"color": "white", "width": 1}}, opacity=0.85)) |
| values = np.random.normal(100, 15, 500) # 500 values, mean=100, std=15 | ||
|
|
||
| # Calculate histogram bins | ||
| counts, bin_edges = np.histogram(values, bins=20) |
There was a problem hiding this comment.
The number of bins should be 30 to match the spec and other library implementations. Currently using 20 bins.
Change line 16 to:
counts, bin_edges = np.histogram(values, bins=30)| counts, bin_edges = np.histogram(values, bins=20) | |
| counts, bin_edges = np.histogram(values, bins=30) |
Summary
Adds
histogram-basicplot implementation.Libraries
Links
specs/histogram-basic.md🤖 Auto-generated by pyplots CI