hist.plot module#

hist.plot.hist2dplot(H, xbins=None, ybins=None, labels=None, cbar=True, cbarsize='7%', cbarpad=0.2, cbarpos='right', cbarextend=True, cmin=None, cmax=None, ax=None, flow='hint', **kwargs)#

Create a 2D histogram plot from np.histogram-like inputs.

Parameters:
  • H (object) –

    Histogram object with containing values and optionally bins. Can be:

    • np.histogram tuple

    • boost_histogram histogram object

    • raw histogram values as list of list or 2d-array

  • xbins (1D array-like, optional, default None) – Histogram bins along x axis, if not part of H.

  • ybins (1D array-like, optional, default None) – Histogram bins along y axis, if not part of H.

  • labels (2D array (H-like) or bool, default None, optional) – Array of per-bin labels to display. If True will display numerical values

  • cbar (bool, optional, default True) – Draw a colorbar. In contrast to mpl behaviors the cbar axes is appended in such a way that it doesn’t modify the original axes width:height ratio.

  • cbarsize (str or float, optional, default "7%") – Colorbar width.

  • cbarpad (float, optional, default 0.2) – Colorbar distance from main axis.

  • cbarpos ({'right', 'left', 'bottom', 'top'}, optional, default "right") – Colorbar position w.r.t main axis.

  • cbarextend (bool, optional, default False) – Extends figure size to keep original axes size same as without cbar. Only safe for 1 axes per fig.

  • cmin (float, optional) – Colorbar minimum.

  • cmax (float, optional) – Colorbar maximum.

  • ax (matplotlib.axes.Axes, optional) – Axes object (if None, last one is fetched or one is created)

  • flow (str, optional {"show", "sum","hint", None}) – Whether plot the under/overflow bin. If “show”, add additional under/overflow bin. If “sum”, add the under/overflow bin content to first/last bin. “hint” would highlight the bins with under/overflow contents

  • **kwargs – Keyword arguments passed to underlying matplotlib function - pcolormesh.

Return type:

Hist2DArtist

hist.plot.histplot(H, bins=None, *, yerr: ArrayLike | bool | None = None, w2=None, w2method=None, stack=False, density=False, binwnorm=None, histtype='step', xerr=False, label=None, sort=None, edges=True, binticks=False, ax=None, flow='hint', **kwargs)#

Create a 1D histogram plot from np.histogram-like inputs.

Parameters:
  • H (object) –

    Histogram object with containing values and optionally bins. Can be:

    • np.histogram tuple

    • PlottableProtocol histogram object

    • boost_histogram classic (<0.13) histogram object

    • raw histogram values, provided bins is specified.

    Or list thereof.

  • bins (iterable, optional) – Histogram bins, if not part of H.

  • yerr (iterable or bool, optional) – Histogram uncertainties. Following modes are supported: - True, sqrt(N) errors or poissonian interval when w2 is specified - shape(N) array of for one sided errors or list thereof - shape(Nx2) array of for two sided errors or list thereof

  • w2 (iterable, optional) – Sum of the histogram weights squared for poissonian interval error calculation

  • w2method (callable, optional) – Function calculating CLs with signature low, high = fcn(w, w2). Here low and high are given in absolute terms, not relative to w. Default is None. If w2 has integer values (likely to be data) poisson interval is calculated, otherwise the resulting error is symmetric sqrt(w2). Specifying poisson or sqrt will force that behaviours.

  • stack (bool, optional) – Whether to stack or overlay non-axis dimension (if it exists). N.B. in contrast to ROOT, stacking is performed in a single call aka histplot([h1, h2, ...], stack=True) as opposed to multiple calls.

  • density (bool, optional) – If true, convert sum weights to probability density (i.e. integrates to 1 over domain of axis) (Note: this option conflicts with binwnorm)

  • binwnorm (float, optional) –

    If true, convert sum weights to bin-width-normalized, with unit equal to

    supplied value (usually you want to specify 1.)

  • histtype ({'step', 'fill', 'band', 'errorbar'}, optional, default: "step") –

    Type of histogram to plot:

    • ”step”: skyline/step/outline of a histogram using plt.stairs

    • ”fill”: filled histogram using plt.stairs

    • ”step”: filled band spanning the yerr range of the histogram using plt.stairs

    • ”errorbar”: single marker histogram using plt.errorbar

  • xerr (bool or float, optional) – Size of xerr if histtype == 'errorbar'. If True, bin-width will be used.

  • label (str or list, optional) – Label for legend entry.

  • sort ({'label'/'l', 'yield'/'y'}, optional) – Append ‘_r’ for reverse.

  • edges (bool, default: True, optional) – Specifies whether to draw first and last edges of the histogram

  • binticks (bool, default: False, optional) – Attempts to draw x-axis ticks coinciding with bin boundaries if feasible.

  • ax (matplotlib.axes.Axes, optional) – Axes object (if None, last one is fetched or one is created)

  • flow (str, optional { "show", "sum", "hint", "none"}) – Whether plot the under/overflow bin. If “show”, add additional under/overflow bin. If “sum”, add the under/overflow bin content to first/last bin.

  • **kwargs – Keyword arguments passed to underlying matplotlib functions - {‘stairs’, ‘errorbar’}.

Return type:

List[Hist1DArtists]

hist.plot.plot2d_full(self: BaseHist, *, ax_dict: dict[str, Axes] | None = None, **kwargs: Any) tuple[ColormeshArtists, StairsArtists | ErrorBarArtists, StairsArtists | ErrorBarArtists]#

Plot2d_full method for BaseHist object.

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

hist.plot.plot_pie(self: BaseHist, *, ax: Axes | None = None, **kwargs: Any) Any#
hist.plot.plot_pull_array(__hist: BaseHist, pulls: ndarray[Any, dtype[Any]], ax: Axes, bar_kwargs: dict[str, Any], pp_kwargs: dict[str, Any]) PullArtists#

Plot a pull plot on the given axes

hist.plot.plot_ratio_array(__hist: BaseHist, ratio: ndarray[Any, dtype[Any]], ratio_uncert: ndarray[Any, dtype[Any]], ax: Axes, **kwargs: Any) RatioErrorbarArtists | RatioBarArtists#

Plot a ratio plot on the given axes

hist.plot.plot_stack(self: Stack, *, ax: Axes | None = None, legend: bool | None = False, **kwargs: Any) Any#