Repository navigation
FEA: Add histograms, 2D histograms and density contours - #170
Merged
Merged
Conversation
Add the binning module with numpy's bin rules and edge semantics, MATLAB's integers rule and normalisations, weights, explicit ranges and a summary of excluded samples, in one and two dimensions.
Add hist, hists, hist_counts, hist2d and density_contour to the facade. Bin samples with the binning module, which now takes the bin types of the model, and store bars, stairs or cells with a record of how they were binned, including the resolved bin edges, so that datatips read the count and density of a whole bin. Share the placement of grouped and stacked columns between the bars and hists helpers.
thclark
added a commit
that referenced
this pull request
Oct 26, 2026
* FEA: Add histogram binning rules and normalisations Add the binning module with numpy's bin rules and edge semantics, MATLAB's integers rule and normalisations, weights, explicit ranges and a summary of excluded samples, in one and two dimensions. * FEA: Add histograms, 2D histograms and density contours Add hist, hists, hist_counts, hist2d and density_contour to the facade. Bin samples with the binning module, which now takes the bin types of the model, and store bars, stairs or cells with a record of how they were binned, including the resolved bin edges, so that datatips read the count and density of a whole bin. Share the placement of grouped and stacked columns between the bars and hists helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 5 of the bars and histograms epic. It delivers the histogram (#93) and the 2D histogram (#94).
Binning
The binning module provides:
It follows numpy 2.3, and its tests cite the numpy call for each expected value. It uses the model's
Bins,BinRuleandHistNorm. Non-finite and out-of-range samples are excluded and reported. A bad bin specification never panics; it draws nothing and is reported by the handle'serror().Facade calls
histdraws touching bars, or stairs for the step and filled-step styles.histsdraws stacked or grouped histograms of several samples on shared bins, using the same placement code asbars.hist_countsdraws pre-binned counts.hist2ddraws cells, with its counts stored so that colour-scale limits and colourbars work.density_contourdraws a contour on the bin centres, with the contour artist unchanged.Stored records (ADR 0029)
Each histogram stores a record of how it was binned: the bins as given, the resolved edges, the range, the normalisation, the total and the exclusions. Datatips read each whole bin's count and density from the record, including for grouped members.
Documentation
The getting-started guide gains a Histograms section, and the equivalent-functions reference and the figure schema are updated.
Existing gallery figures render byte-identically.