Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Assign value-axis label #431

Open
goi42 opened this issue Jul 13, 2022 · 0 comments
Open

[FEATURE] Assign value-axis label #431

goi42 opened this issue Jul 13, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@goi42
Copy link

goi42 commented Jul 13, 2022

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:

  1. 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.
    1. 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.
  2. It streamlines coding.
    1. As it is, I have to retrieve it from the metadata (or just remember what it means) and plot it manually.
    2. 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant