Skip to content

Investigate implementation of hist library over np.histogram in notebooks #77

@AntonioJC

Description

@AntonioJC

Usage of hist library in notebooks can be beneficial over np.histogram, including handling uncertainties and also convenient access to plotting functionality: https://hist.readthedocs.io/.

Example and suggestion from @alexander-held below.

import hist

h = hist.Hist.new.Regular(60, 100, 160, label="di-photon invariant mass $m_{yy}$ [GeV]", flow=False).Double()

before your iterate loop starts and then inside your loop

h.fill(data['mass'])

and finally

fig, ax = plt.subplots()
h.plot(ax=ax, histtype="errorbar", color="black", label="Data")
ax.set_ylabel("Events / 1 GeV")
ax.set_ylim([0, ax.get_ylim()[1]*1.1])
ax.set_xlim([100, 160])
ax.legend( frameon=False )

produces a plot very similar to the one being done right now.

Originally posted by @alexander-held in #75 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions