hist package#
- class hist.BaseHist(arg: dict[str, Any], /, *, data: NDArray[Any] | None = ..., metadata: Any = ..., label: str | None = ..., name: str | None = ...)#
- class hist.BaseHist(arg: Self | bh.Histogram[S], /, *, data: NDArray[Any] | None = ..., metadata: Any = ..., label: str | None = ..., name: str | None = ...)
- class hist.BaseHist(*axes: AxisProtocol | tuple[int, float, float] | Storage | str, storage: S = ..., metadata: Any = ..., data: NDArray[Any] | None = ..., label: str | None = ..., name: str | None = ...)
Bases:
Histogram[S],Generic[S]- property T: Self#
- expand_cats(*, name: Callable[..., str] | None = None) dict[str, Self]#
Expand all categorical axes into a dict of histograms.
One histogram is produced for every combination of categories. The
namecallable receives the category values, one per categorical axis, and returns the key; the default joins them with_.
- fill(*args: ArrayLike, weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) Self#
Insert data into the histogram using names and indices, return a Hist object.
- fill_flattened(*args: Any, weight: Any | None = None, sample: Any | None = None, threads: int | None = None, **kwargs: Any) Self#
- classmethod from_columns(data: Mapping[str, ArrayLike], axes: Sequence[str | AxisProtocol], *, weight: str | None = None, storage: hist.storage.Storage | None = None) Self#
- integrate(name: int | str, i_or_list: list[str | int], j: InnerIndexing | None = None) Self#
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) IntHists | int
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) FloatHists | float
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) ListHists | list[float]
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) WeightHists | WeightedSum
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) MeanHists | Mean
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) WeightedMeanHists | WeightedMean
- integrate(name: int | str, i_or_list: InnerIndexing | None = None, j: InnerIndexing | None = None) Self | int | float | list[float] | bh.accumulators.Accumulator
- 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, legend: bool = True, **kwargs: Any) Hist1DArtists#
Plot1d method for BaseHist object.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, uses current axes or creates new ones.
overlay (str or int, optional) – Name or index of the axis to overlay. If None, automatically selects the first discrete axis for multi-dimensional histograms.
legend (bool, default True) – Whether to automatically add a legend when plotting stacked categories. The legend title is set from the axis label if available.
**kwargs (Any) – Additional keyword arguments passed to the underlying plot functions.
- Returns:
The matplotlib artists created by the plot.
- Return type:
Hist1DArtists
- 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_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_pullmethod forBaseHistobject.Return a tuple of artists following a structure of
(main_ax_artists, subplot_ax_artists)
- plot_ratio(other: hist.BaseHist[Any] | 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_ratiomethod forBaseHistobject.Return a tuple of artists following a structure of
(main_ax_artists, subplot_ax_artists)
- profile(axis: int | str) Self#
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.
- sort(axis: int | str, key: Callable[[int], SupportsLessThan] | Callable[[str], SupportsLessThan] | None = None, reverse: bool = False) Self#
Sort a categorical axis.
- class hist.Hist(arg: dict[str, Any], /, *, data: NDArray[Any] | None = ..., metadata: Any = ..., label: str | None = ..., name: str | None = ...)#
- class hist.Hist(arg: Self | bh.Histogram[S], /, *, data: NDArray[Any] | None = ..., metadata: Any = ..., label: str | None = ..., name: str | None = ...)
- class hist.Hist(*axes: AxisProtocol | tuple[int, float, float] | Storage | str, storage: S = ..., metadata: Any = ..., data: NDArray[Any] | None = ..., label: str | None = ..., name: str | None = ...)
- class hist.NamedHist(*args: Any, **kwargs: Any)#
Bases:
BaseHist[S],Generic[S]- fill(weight: ArrayLike | None = None, sample: ArrayLike | None = None, threads: int | None = None, **kwargs: ArrayLike) Self#
Insert data into the histogram using names and return a NamedHist object. NamedHist could only be filled by names.
- class hist.Stack(*args: BaseHist[S])#
Bases:
Generic[S]- property axes: NamedAxesTuple#
- classmethod from_dict(d: Mapping[str, BaseHist[S]]) Self#
Create a Stack from a dictionary of histograms. The keys of the dictionary are used as names.
- class hist.rebin(factor_or_axis: int | PlottableAxis | None = None, /, *, factor: int | None = None, groups: Sequence[int] | None = None, edges: Sequence[int | float] | None = None, axis: PlottableAxis | None = None)#
Bases:
object- axis#
- edges#
- factor#
- group_mapping(axis: PlottableAxis) Sequence[int]#
Return the list of group sizes (numbers of adjacent bins to merge) for
axis. For explicit groups, the sum of the group sizes must equal the number of bins in the axis. For a factor, this returnslen(axis) // factorgroups of sizefactor; if the factor does not divide the number of bins evenly, the leftover bins are not part of any group (a consumer should merge them into the overflow bin, matching the C++ factor-based rebinning).
- groups#
- 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.
Subpackages#
Submodules#
- hist.accumulators module
- hist.axestuple module
- hist.basehist module
BaseHistBaseHist.TBaseHist.density()BaseHist.expand_cats()BaseHist.fill()BaseHist.fill_flattened()BaseHist.from_columns()BaseHist.integrate()BaseHist.plot()BaseHist.plot1d()BaseHist.plot2d()BaseHist.plot2d_full()BaseHist.plot_pie()BaseHist.plot_pull()BaseHist.plot_ratio()BaseHist.profile()BaseHist.project()BaseHist.show()BaseHist.sort()BaseHist.stack()
SupportsLessThanprocess_mistaken_quick_construct()
- hist.classichist module
- hist.hist module
- hist.intervals module
- hist.namedhist module
- hist.numpy module
- hist.plot module
- hist.quick_construct module
ConstructProxyMetaConstructorQuickConstructQuickConstruct.Bool()QuickConstruct.Boolean()QuickConstruct.Func()QuickConstruct.Int()QuickConstruct.IntCat()QuickConstruct.IntCategory()QuickConstruct.Integer()QuickConstruct.Log()QuickConstruct.Pow()QuickConstruct.Reg()QuickConstruct.Regular()QuickConstruct.Sqrt()QuickConstruct.StrCat()QuickConstruct.StrCategory()QuickConstruct.Var()QuickConstruct.Variable()QuickConstruct.axesQuickConstruct.hist_class
- hist.stack module
- hist.storage module
- hist.svgplots module
- hist.svgutils module
- hist.tag module
- hist.version module