Skip to content

Differences from numpy and others ​

numpy ​

The rules, the edges and the counts follow numpy.histogram and numpy.histogram_bin_edges (numpy 2.5). The test suite compares this plugin with numpy's own output on 27 datasets, for the seven rules and for fixed counts, and on weighted data. Edges agree within 10⁻¹² of the largest edge, and counts agree exactly. The cases below differ on purpose.

CasenumpyThis pluginWhy
All values equal, with a fixed countSpreads the bins over [v − 0.5, v + 0.5]One bin of width 1 centered on the valueSeveral empty bins around one value add nothing
doane on fewer than 3 valuesOne binFalls back to sturgesThe skewness of 1 or 2 values is not defined
fd when the interquartile range is 0One binFalls back to sturgesOne bin hides all the data
A rule with weightsRefuses: "Automated estimation of the number of bins is not supported for weighted data"Chooses the count from the values, without their weightsA chart should draw something
NaN, Infinity or non-numbers in the dataRaises an errorLeaves them out and counts them in droppedReal data has gaps
Inner edgesstart + i × step, as computedRounded to 14 significant digits when the difference is only rounding noise: 0.3, not 0.30000000000000004Readable tooltips and ticks; the change is below 4 units in the last place
Negative weightsAcceptedLeft out with invalid-weightsThey would draw bars below the axis and break densities

With weights, numpy adds the weights in another order, so counts agree within 10⁻¹² of the total weight rather than exactly.

Coming from Highcharts ​

HighchartsThis plugin
binsNumber: 'square-root', 'sturges', 'rice'bins with the same names
binsNumber: 10bins: 10
binWidthbinWidth
baseSeriessource
A column series with pointPadding: 0 for pre-counted binsparsing: false with {x0, x1, y} records

The default rule differs: Highcharts uses 'square-root'; this plugin uses 'auto'.

Coming from Plotly ​

PlotlyThis plugin
nbinsxbins (Plotly treats it as a maximum; here it is the count)
xbins: {start, end, size}binStart, domain and binWidth
histnorm: 'percent'stat: 'percent'
histnorm: 'probability'stat: 'relative'
histnorm: 'probability density'stat: 'density'
cumulative: {enabled: true, direction: 'decreasing'}cumulative: 'reverse'
bingroupbinGroup

Released under the MIT License.