hist
hist copied to clipboard
[FEATURE] Assign value-axis label
I would like to be able to assign a label to the value axis of a histogram, e.g., the vertical axis of a 1D histogram. (See #425.)
Why:
- The meaning of the value axis is a property of the histogram, so it makes logical sense that it would be a property of the Hist object.
- That is to say, the appropriate value-axis label can vary wildly between histograms, especially if they were weighted, normalized, or represent some physical parameter value.
- It streamlines coding.
- As it is, I have to retrieve it from the metadata (or just remember what it means) and plot it manually.
- This is particularly egregious when one saves the histogram to a file for later retrieval. Using uproot, for example, one currently ends up saving a 1D histogram as a TH1D with an x-axis label and no y-axis label. Any metadata is lost, so if one wants to save the y-axis label, one has to store it as a separate object in the file.
Example of desired behavior:
import hist
h = hist.Hist(hist.axis.Regular(50, 0, 50, label="x"), count_label="y")
h.plot()
Approximately equivalent to:
import hist
import matplotlib.pyplot as plt
h = hist.Hist(hist.axis.Regular(50, 0, 50, label="x"))
fig, ax = plt.subplots()
a = h.plot(ax=ax)
ax.set_ylabel("y")