hist package

Submodules

hist.accumulators module

class hist.accumulators.Mean

Bases: pybind11_builtins.pybind11_object

property count
fill(self: boost_histogram._core.accumulators.Mean, value: object, *, weight: object = None) boost_histogram._core.accumulators.Mean

Fill the accumulator with values. Optional weight parameter.

property value
property variance
class hist.accumulators.Sum

Bases: pybind11_builtins.pybind11_object

fill(self: boost_histogram._core.accumulators.Sum, value: object) boost_histogram._core.accumulators.Sum

Run over an array with the accumulator

property value
class hist.accumulators.WeightedMean

Bases: pybind11_builtins.pybind11_object

fill(self: boost_histogram._core.accumulators.WeightedMean, value: object, *, weight: object = None) boost_histogram._core.accumulators.WeightedMean

Fill the accumulator with values. Optional weight parameter.

property sum_of_weights
property sum_of_weights_squared
property value
property variance
class hist.accumulators.WeightedSum

Bases: pybind11_builtins.pybind11_object

fill(self: boost_histogram._core.accumulators.WeightedSum, value: object, *, variance: object = None) boost_histogram._core.accumulators.WeightedSum

Fill the accumulator with values. Optional variance parameter.

property value
property variance

hist.axestuple module

class hist.axestuple.ArrayTuple(iterable=(), /)

Bases: tuple

broadcast() boost_histogram._internal.axestuple.A

The arrays in this tuple will be compressed if possible to save memory. Use this method to broadcast them out into their full memory representation.

class hist.axestuple.AxesTuple(iterable=(), /)

Bases: tuple

bin(*indexes: float) Tuple[float, ...]

Return the edges of the bins as a tuple for a continuous axis or the bin value for a non-continuous axis, when given an index.

property centers: boost_histogram.axis.ArrayTuple
property edges: boost_histogram.axis.ArrayTuple
property extent: Tuple[int, ...]
index(*values: float) Tuple[float, ...]

Return the fractional index(es) given a value (or values) on the axis.

property size: Tuple[int, ...]
value(*indexes: float) Tuple[float, ...]

Return the value(s) given an (fractional) index (or indices).

property widths: boost_histogram.axis.ArrayTuple
class hist.axestuple.NamedAxesTuple(iterable=(), /)

Bases: boost_histogram.axis.AxesTuple

property label: tuple[str]

The labels of the axes. Defaults to name if label not given, or Axis N if neither was given.

property name: tuple[str]

The names of the axes. May be empty strings.

hist.basehist module

class hist.basehist.BaseHist(*args: AxisProtocol | Storage | str | tuple[int, float, float], storage: Storage | str | None = None, metadata: Any = None, data: np.typing.NDArray[Any] | None = None, label: str | None = None, name: str | None = None)

Bases: boost_histogram.Histogram

density() np.typing.NDArray[Any]

Density NumPy array.

fill(*args: ArrayLike, weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) T

Insert data into the histogram using names and indices, return a Hist object.

classmethod from_columns(data: Mapping[str, ArrayLike], axes: Sequence[str | AxisProtocol], *, weight: str | None = None, storage: hist.storage.Storage = Double()) T
plot(*args: Any, overlay: str | None = None, **kwargs: Any) Hist1DArtists | Hist2DArtists

Plot method for BaseHist object.

plot1d(*, ax: matplotlib.axes.Axes | None = None, overlay: str | int | None = None, **kwargs: Any) Hist1DArtists

Plot1d method for BaseHist object.

plot2d(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Hist2DArtists

Plot2d method for BaseHist object.

plot2d_full(*, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[Hist2DArtists, Hist1DArtists, Hist1DArtists]

Plot2d_full method for BaseHist object.

Pass a dict of axes to ax_dict, otherwise, the current figure will be used.

plot_pie(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Any
plot_pull(func: Callable[[np.typing.NDArray[Any]], np.typing.NDArray[Any]] | str, *, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[FitResultArtists, RatiolikeArtists]

plot_pull method for BaseHist object.

Return a tuple of artists following a structure of (main_ax_artists, subplot_ax_artists)

plot_ratio(other: hist.BaseHist | Callable[[np.typing.NDArray[Any]], np.typing.NDArray[Any]] | str, *, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[MainAxisArtists, RatiolikeArtists]

plot_ratio method for BaseHist object.

Return a tuple of artists following a structure of (main_ax_artists, subplot_ax_artists)

profile(axis: int | str) T

Returns a profile (Mean/WeightedMean) histogram from a normal histogram with N-1 axes. The axis given is profiled over and removed from the final histogram.

project(*args: int | str) T | float | bh.accumulators.Accumulator

Projection of axis idx.

show(**kwargs: Any) Any

Pretty print histograms to the console.

sort(axis: int | str, key: Callable[[int], SupportsLessThan] | Callable[[str], SupportsLessThan] | None = None, reverse: bool = False) T

Sort a categorical axis.

stack(axis: int | str) hist.stack.Stack

Returns a stack from a normal histogram axes.

class hist.basehist.SupportsLessThan(*args, **kwargs)

Bases: Protocol

hist.classichist module

hist.classichist.main() None

hist.hist module

class hist.hist.Hist(*args: AxisProtocol | Storage | str | tuple[int, float, float], storage: Storage | str | None = None, metadata: Any = None, data: np.typing.NDArray[Any] | None = None, label: str | None = None, name: str | None = None)

Bases: hist.basehist.BaseHist

hist.intervals module

hist.intervals.clopper_pearson_interval(num: np.typing.NDArray[Any], denom: np.typing.NDArray[Any], coverage: float | None = None) np.typing.NDArray[Any]

Compute the Clopper-Pearson coverage interval for a binomial distribution. c.f. http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval

Parameters
  • num – Numerator or number of successes.

  • denom – Denominator or number of trials.

  • coverage – Central coverage interval. Default is one standard deviation, which is roughly 0.68.

Returns

The Clopper-Pearson central coverage interval.

hist.intervals.poisson_interval(values: np.typing.NDArray[Any], variances: np.typing.NDArray[Any] | None = None, coverage: float | None = None) np.typing.NDArray[Any]

The Frequentist coverage interval for Poisson-distributed observations.

What is calculated is the “Garwood” interval, c.f. V. Patil, H. Kulkarni (Revstat, 2012) or http://ms.mcmaster.ca/peter/s743/poissonalpha.html. If variances is supplied, the data is assumed to be weighted, and the unweighted count is approximated by values**2/variances, which effectively scales the unweighted Poisson interval by the average weight. This may not be the optimal solution: see 10.1016/j.nima.2014.02.021 (arXiv:1309.1287) for a proper treatment.

In cases where the value is zero, an upper limit is well-defined only in the case of unweighted data, so if variances is supplied, the upper limit for a zero value will be set to NaN.

Parameters
  • values – Sum of weights.

  • variances – Sum of weights squared.

  • coverage – Central coverage interval. Default is one standard deviation, which is roughly 0.68.

Returns

The Poisson central coverage interval.

hist.intervals.ratio_uncertainty(num: np.typing.NDArray[Any], denom: np.typing.NDArray[Any], uncertainty_type: Literal['poisson', 'poisson-ratio', 'efficiency'] = 'poisson') Any

Calculate the uncertainties for the values of the ratio num/denom using the specified coverage interval approach.

Parameters
  • num – Numerator or number of successes.

  • denom – Denominator or number of trials.

  • uncertainty_type

    Coverage interval type to use in the calculation of the uncertainties.

    • "poisson" (default) implements the Garwood confidence interval for a Poisson-distributed numerator scaled by the denominator. See hist.intervals.poisson_interval() for further details.

    • "poisson-ratio" implements a confidence interval for the ratio num / denom assuming it is an estimator of the ratio of the expected rates from two independent Poisson distributions. It over-covers to a similar degree as the Clopper-Pearson interval does for the Binomial efficiency parameter estimate.

    • "efficiency" implements the Clopper-Pearson confidence interval for the ratio num / denom assuming it is an estimator of a Binomial efficiency parameter. This is only valid if the entries contributing to num are a strict subset of those contributing to denom.

Returns

The uncertainties for the ratio.

hist.namedhist module

class hist.namedhist.NamedHist(*args: Any, **kwargs: Any)

Bases: hist.basehist.BaseHist

fill(weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) T

Insert data into the histogram using names and return a NamedHist object. NamedHist could only be filled by names.

project(*args: int | str) T | float | bh.accumulators.Accumulator

Projection of axis idx.

hist.numpy module

hist.numpy.histogram(a: object, bins: int = 10, range: Optional[Tuple[float, float]] = None, normed: None = None, weights: Optional[object] = None, density: bool = False, *, histogram: Optional[Type[boost_histogram.Histogram]] = None, storage: Optional[boost_histogram._internal.storage.Storage] = None, threads: Optional[int] = None) Any

Return a boost-histogram object using the same arguments as numpy’s histogram. This does not support the deprecated normed=True argument. Three extra arguments are added: histogram=bh.Histogram will enable object based output, storage=bh.storage.* lets you set the storage used, and threads=int lets you set the number of threads to fill with (0 for auto, None for 1).

Compute the histogram of a dataset.

Parameters
  • a (array_like) – Input data. The histogram is computed over the flattened array.

  • bins (int or sequence of scalars or str, optional) –

    If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.

    New in version 1.11.0.

    If bins is a string, it defines the method used to calculate the optimal bin width, as defined by histogram_bin_edges.

  • range ((float, float), optional) – The lower and upper range of the bins. If not provided, range is simply (a.min(), a.max()). Values outside the range are ignored. The first element of the range must be less than or equal to the second. range affects the automatic bin computation as well. While bin width is computed to be optimal based on the actual data within range, the bin count will fill the entire range including portions containing no data.

  • normed (bool, optional) –

    Deprecated since version 1.6.0.

    This is equivalent to the density argument, but produces incorrect results for unequal bin widths. It should not be used.

    Changed in version 1.15.0: DeprecationWarnings are actually emitted.

  • weights (array_like, optional) – An array of weights, of the same shape as a. Each value in a only contributes its associated weight towards the bin count (instead of 1). If density is True, the weights are normalized, so that the integral of the density over the range remains 1.

  • density (bool, optional) –

    If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function.

    Overrides the normed keyword if given.

Returns

  • hist (array) – The values of the histogram. See density and weights for a description of the possible semantics.

  • bin_edges (array of dtype float) – Return the bin edges (length(hist)+1).

See also

histogramdd, bincount, searchsorted, digitize, histogram_bin_edges

Notes

All but the last (righthand-most) bin is half-open. In other words, if bins is:

[1, 2, 3, 4]

then the first bin is [1, 2) (including 1, but excluding 2) and the second [2, 3). The last bin, however, is [3, 4], which includes 4.

Examples

>>> np.histogram([1, 2, 1], bins=[0, 1, 2, 3])
(array([0, 2, 1]), array([0, 1, 2, 3]))
>>> np.histogram(np.arange(4), bins=np.arange(5), density=True)
(array([0.25, 0.25, 0.25, 0.25]), array([0, 1, 2, 3, 4]))
>>> np.histogram([[1, 2, 1], [1, 0, 1]], bins=[0,1,2,3])
(array([1, 4, 1]), array([0, 1, 2, 3]))
>>> a = np.arange(5)
>>> hist, bin_edges = np.histogram(a, density=True)
>>> hist
array([0.5, 0. , 0.5, 0. , 0. , 0.5, 0. , 0.5, 0. , 0.5])
>>> hist.sum()
2.4999999999999996
>>> np.sum(hist * np.diff(bin_edges))
1.0

New in version 1.11.0.

Automated Bin Selection Methods example, using 2 peak random data with 2000 points:

>>> import matplotlib.pyplot as plt
>>> rng = np.random.RandomState(10)  # deterministic random data
>>> a = np.hstack((rng.normal(size=1000),
...                rng.normal(loc=5, scale=2, size=1000)))
>>> _ = plt.hist(a, bins='auto')  # arguments are passed to np.histogram
>>> plt.title("Histogram with 'auto' bins")
Text(0.5, 1.0, "Histogram with 'auto' bins")
>>> plt.show()
hist.numpy.histogram2d(x: object, y: object, bins: Union[int, Tuple[int, int]] = 10, range: Optional[Sequence[Union[None, Tuple[float, float]]]] = None, normed: None = None, weights: Optional[object] = None, density: bool = False, *, histogram: Optional[Type[boost_histogram.Histogram]] = None, storage: boost_histogram._internal.storage.Storage = Double(), threads: Optional[int] = None) Any

Return a boost-histogram object using the same arguments as numpy’s histogram2d. This does not support the deprecated normed=True argument. Three extra arguments are added: histogram=bh.Histogram will enable object based output, storage=bh.storage.* lets you set the storage used, and threads=int lets you set the number of threads to fill with (0 for auto, None for 1).

Compute the bi-dimensional histogram of two data samples.

Parameters
  • x (array_like, shape (N,)) – An array containing the x coordinates of the points to be histogrammed.

  • y (array_like, shape (N,)) – An array containing the y coordinates of the points to be histogrammed.

  • bins (int or array_like or [int, int] or [array, array], optional) –

    The bin specification:

    • If int, the number of bins for the two dimensions (nx=ny=bins).

    • If array_like, the bin edges for the two dimensions (x_edges=y_edges=bins).

    • If [int, int], the number of bins in each dimension (nx, ny = bins).

    • If [array, array], the bin edges in each dimension (x_edges, y_edges = bins).

    • A combination [int, array] or [array, int], where int is the number of bins and array is the bin edges.

  • range (array_like, shape(2,2), optional) – The leftmost and rightmost edges of the bins along each dimension (if not specified explicitly in the bins parameters): [[xmin, xmax], [ymin, ymax]]. All values outside of this range will be considered outliers and not tallied in the histogram.

  • density (bool, optional) – If False, the default, returns the number of samples in each bin. If True, returns the probability density function at the bin, bin_count / sample_count / bin_area.

  • normed (bool, optional) – An alias for the density argument that behaves identically. To avoid confusion with the broken normed argument to histogram, density should be preferred.

  • weights (array_like, shape(N,), optional) – An array of values w_i weighing each sample (x_i, y_i). Weights are normalized to 1 if normed is True. If normed is False, the values of the returned histogram are equal to the sum of the weights belonging to the samples falling into each bin.

Returns

  • H (ndarray, shape(nx, ny)) – The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.

  • xedges (ndarray, shape(nx+1,)) – The bin edges along the first dimension.

  • yedges (ndarray, shape(ny+1,)) – The bin edges along the second dimension.

See also

histogram

1D histogram

histogramdd

Multidimensional histogram

Notes

When normed is True, then the returned histogram is the sample density, defined such that the sum over bins of the product bin_value * bin_area is 1.

Please note that the histogram does not follow the Cartesian convention where x values are on the abscissa and y values on the ordinate axis. Rather, x is histogrammed along the first dimension of the array (vertical), and y along the second dimension of the array (horizontal). This ensures compatibility with histogramdd.

Examples

>>> from matplotlib.image import NonUniformImage
>>> import matplotlib.pyplot as plt

Construct a 2-D histogram with variable bin width. First define the bin edges:

>>> xedges = [0, 1, 3, 5]
>>> yedges = [0, 2, 3, 4, 6]

Next we create a histogram H with random bin content:

>>> x = np.random.normal(2, 1, 100)
>>> y = np.random.normal(1, 1, 100)
>>> H, xedges, yedges = np.histogram2d(x, y, bins=(xedges, yedges))
>>> # Histogram does not follow Cartesian convention (see Notes),
>>> # therefore transpose H for visualization purposes.
>>> H = H.T

imshow can only display square bins:

>>> fig = plt.figure(figsize=(7, 3))
>>> ax = fig.add_subplot(131, title='imshow: square bins')
>>> plt.imshow(H, interpolation='nearest', origin='lower',
...         extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]])
<matplotlib.image.AxesImage object at 0x...>

pcolormesh can display actual edges:

>>> ax = fig.add_subplot(132, title='pcolormesh: actual edges',
...         aspect='equal')
>>> X, Y = np.meshgrid(xedges, yedges)
>>> ax.pcolormesh(X, Y, H)
<matplotlib.collections.QuadMesh object at 0x...>

NonUniformImage can be used to display actual bin edges with interpolation:

>>> ax = fig.add_subplot(133, title='NonUniformImage: interpolated',
...         aspect='equal', xlim=xedges[[0, -1]], ylim=yedges[[0, -1]])
>>> im = NonUniformImage(ax, interpolation='bilinear')
>>> xcenters = (xedges[:-1] + xedges[1:]) / 2
>>> ycenters = (yedges[:-1] + yedges[1:]) / 2
>>> im.set_data(xcenters, ycenters, H)
>>> ax.images.append(im)
>>> plt.show()
hist.numpy.histogramdd(a: Tuple[object, ...], bins: Union[int, Tuple[int, ...]] = 10, range: Optional[Sequence[Union[None, Tuple[float, float]]]] = None, normed: None = None, weights: Optional[object] = None, density: bool = False, *, histogram: Optional[Type[boost_histogram.Histogram]] = None, storage: boost_histogram._internal.storage.Storage = Double(), threads: Optional[int] = None) Any

Return a boost-histogram object using the same arguments as numpy’s histogramdd. This does not support the deprecated normed=True argument. Three extra arguments are added: histogram=bh.Histogram will enable object based output, storage=bh.storage.* lets you set the storage used, and threads=int lets you set the number of threads to fill with (0 for auto, None for 1).

Compute the multidimensional histogram of some data.

Parameters
  • sample ((N, D) array, or (D, N) array_like) –

    The data to be histogrammed.

    Note the unusual interpretation of sample when an array_like:

    • When an array, each row is a coordinate in a D-dimensional space - such as histogramdd(np.array([p1, p2, p3])).

    • When an array_like, each element is the list of values for single coordinate - such as histogramdd((X, Y, Z)).

    The first form should be preferred.

  • bins (sequence or int, optional) –

    The bin specification:

    • A sequence of arrays describing the monotonically increasing bin edges along each dimension.

    • The number of bins for each dimension (nx, ny, … =bins)

    • The number of bins for all dimensions (nx=ny=…=bins).

  • range (sequence, optional) – A sequence of length D, each an optional (lower, upper) tuple giving the outer bin edges to be used if the edges are not given explicitly in bins. An entry of None in the sequence results in the minimum and maximum values being used for the corresponding dimension. The default, None, is equivalent to passing a tuple of D None values.

  • density (bool, optional) – If False, the default, returns the number of samples in each bin. If True, returns the probability density function at the bin, bin_count / sample_count / bin_volume.

  • normed (bool, optional) – An alias for the density argument that behaves identically. To avoid confusion with the broken normed argument to histogram, density should be preferred.

  • weights ((N,) array_like, optional) – An array of values w_i weighing each sample (x_i, y_i, z_i, …). Weights are normalized to 1 if normed is True. If normed is False, the values of the returned histogram are equal to the sum of the weights belonging to the samples falling into each bin.

Returns

  • H (ndarray) – The multidimensional histogram of sample x. See normed and weights for the different possible semantics.

  • edges (list) – A list of D arrays describing the bin edges for each dimension.

See also

histogram

1-D histogram

histogram2d

2-D histogram

Examples

>>> r = np.random.randn(100,3)
>>> H, edges = np.histogramdd(r, bins = (5, 8, 4))
>>> H.shape, edges[0].size, edges[1].size, edges[2].size
((5, 8, 4), 6, 9, 5)

hist.stack module

class hist.stack.Stack(*args: hist.basehist.BaseHist)

Bases: object

property axes: hist.axestuple.NamedAxesTuple
classmethod from_dict(d: typing.Mapping[str, BaseHist]) T

Create a Stack from a dictionary of histograms. The keys of the dictionary are used as names.

classmethod from_iter(iterable: typing.Iterable[BaseHist]) T

Create a Stack from an iterable of histograms.

plot(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Any

Plot method for Stack object.

project(*args: int | str) T

Project the Stack onto a new axes.

show(**kwargs: Any) Any

Pretty print the stacked histograms to the console.

hist.storage module

class hist.storage.AtomicInt64

Bases: boost_histogram._core.storage.atomic_int64, boost_histogram._internal.storage.Storage

class hist.storage.Double

Bases: boost_histogram._core.storage.double, boost_histogram._internal.storage.Storage

class hist.storage.Int64

Bases: boost_histogram._core.storage.int64, boost_histogram._internal.storage.Storage

class hist.storage.Mean

Bases: boost_histogram._core.storage.mean, boost_histogram._internal.storage.Storage

class hist.storage.Storage

Bases: object

class hist.storage.Unlimited

Bases: boost_histogram._core.storage.unlimited, boost_histogram._internal.storage.Storage

class hist.storage.Weight

Bases: boost_histogram._core.storage.weight, boost_histogram._internal.storage.Storage

class hist.storage.WeightedMean

Bases: boost_histogram._core.storage.weighted_mean, boost_histogram._internal.storage.Storage

hist.tag module

class hist.tag.Locator(offset: int = 0)

Bases: object

NAME = ''
offset
class hist.tag.Slicer

Bases: object

This is a simple class to make slicing inside dictionaries simpler. This is how it should be used:

s = bh.tag.Slicer()

h[{0: s[::bh.rebin(2)]}] # rebin axis 0 by two

class hist.tag.at(value: int)

Bases: object

value
class hist.tag.loc(value: Union[str, float], offset: int = 0)

Bases: boost_histogram.tag.Locator

value
class hist.tag.rebin(value: int)

Bases: object

factor
hist.tag.sum(iterable, /, start=0)

Return the sum of a ‘start’ value (default: 0) plus an iterable of numbers

When the iterable is empty, return the start value. This function is intended specifically for use with numeric values and may reject non-numeric types.

hist.version module

Module contents

class hist.BaseHist(*args: AxisProtocol | Storage | str | tuple[int, float, float], storage: Storage | str | None = None, metadata: Any = None, data: np.typing.NDArray[Any] | None = None, label: str | None = None, name: str | None = None)

Bases: boost_histogram.Histogram

density() np.typing.NDArray[Any]

Density NumPy array.

fill(*args: ArrayLike, weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) T

Insert data into the histogram using names and indices, return a Hist object.

classmethod from_columns(data: Mapping[str, ArrayLike], axes: Sequence[str | AxisProtocol], *, weight: str | None = None, storage: hist.storage.Storage = Double()) T
plot(*args: Any, overlay: str | None = None, **kwargs: Any) Hist1DArtists | Hist2DArtists

Plot method for BaseHist object.

plot1d(*, ax: matplotlib.axes.Axes | None = None, overlay: str | int | None = None, **kwargs: Any) Hist1DArtists

Plot1d method for BaseHist object.

plot2d(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Hist2DArtists

Plot2d method for BaseHist object.

plot2d_full(*, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[Hist2DArtists, Hist1DArtists, Hist1DArtists]

Plot2d_full method for BaseHist object.

Pass a dict of axes to ax_dict, otherwise, the current figure will be used.

plot_pie(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Any
plot_pull(func: Callable[[np.typing.NDArray[Any]], np.typing.NDArray[Any]] | str, *, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[FitResultArtists, RatiolikeArtists]

plot_pull method for BaseHist object.

Return a tuple of artists following a structure of (main_ax_artists, subplot_ax_artists)

plot_ratio(other: hist.BaseHist | Callable[[np.typing.NDArray[Any]], np.typing.NDArray[Any]] | str, *, ax_dict: dict[str, matplotlib.axes.Axes] | None = None, **kwargs: Any) tuple[MainAxisArtists, RatiolikeArtists]

plot_ratio method for BaseHist object.

Return a tuple of artists following a structure of (main_ax_artists, subplot_ax_artists)

profile(axis: int | str) T

Returns a profile (Mean/WeightedMean) histogram from a normal histogram with N-1 axes. The axis given is profiled over and removed from the final histogram.

project(*args: int | str) T | float | bh.accumulators.Accumulator

Projection of axis idx.

show(**kwargs: Any) Any

Pretty print histograms to the console.

sort(axis: int | str, key: Callable[[int], SupportsLessThan] | Callable[[str], SupportsLessThan] | None = None, reverse: bool = False) T

Sort a categorical axis.

stack(axis: int | str) hist.stack.Stack

Returns a stack from a normal histogram axes.

class hist.Hist(*args: AxisProtocol | Storage | str | tuple[int, float, float], storage: Storage | str | None = None, metadata: Any = None, data: np.typing.NDArray[Any] | None = None, label: str | None = None, name: str | None = None)

Bases: hist.basehist.BaseHist

class hist.NamedHist(*args: Any, **kwargs: Any)

Bases: hist.basehist.BaseHist

fill(weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) T

Insert data into the histogram using names and return a NamedHist object. NamedHist could only be filled by names.

project(*args: int | str) T | float | bh.accumulators.Accumulator

Projection of axis idx.

class hist.Stack(*args: hist.basehist.BaseHist)

Bases: object

property axes: hist.axestuple.NamedAxesTuple
classmethod from_dict(d: typing.Mapping[str, BaseHist]) T

Create a Stack from a dictionary of histograms. The keys of the dictionary are used as names.

classmethod from_iter(iterable: typing.Iterable[BaseHist]) T

Create a Stack from an iterable of histograms.

plot(*, ax: matplotlib.axes.Axes | None = None, **kwargs: Any) Any

Plot method for Stack object.

project(*args: int | str) T

Project the Stack onto a new axes.

show(**kwargs: Any) Any

Pretty print the stacked histograms to the console.

class hist.loc(value: Union[str, float], offset: int = 0)

Bases: boost_histogram.tag.Locator

value
class hist.rebin(value: int)

Bases: object

factor
hist.sum(iterable, /, start=0)

Return the sum of a ‘start’ value (default: 0) plus an iterable of numbers

When the iterable is empty, return the start value. This function is intended specifically for use with numeric values and may reject non-numeric types.