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

[BUG] plot2d_full does not work properly on Int axes #488

Open
lfarinaa opened this issue Mar 23, 2023 · 2 comments
Open

[BUG] plot2d_full does not work properly on Int axes #488

lfarinaa opened this issue Mar 23, 2023 · 2 comments

Comments

@lfarinaa
Copy link

Describe the bug

Calling plot2d_full on an (Int,Int)-axes hist produces a garbled side axis.

Also, there is no documentation on how to add a title to a plot2d_full plot.

Steps to reproduce

An example that highlights the broken behaviour. Include OS and system info if relevant.

Reproduce: try this:

h = Hist(
    Hist.new.Int(-5, 5, name="S", label="s [units]", flow=False)
    .Int(-5, 5, name="W", label="w [units]", flow=False)
    .Double()
)
s_data = np.random.normal(size=100_000) + np.ones(100_000)
w_data = np.random.normal(size=100_000)

# normal fill
h.fill(s_data, w_data)

plt.figure(figsize=(8, 8))

h.plot2d_full(
)

plt.show()

image

@henryiii
Copy link
Member

henryiii commented Mar 23, 2023

Few quick tips: No need to wrap Hist.new.<axes>.Double() in Hist(), it's already a Hist! :) You can also use np.random.normal(loc=1, size=100_000) instead of np.random.normal(size=100_000) + np.ones(100_000) to save an addition and temporary memory allocation.

import matplotlib.pyplot as plt
import numpy as np
from hist import Hist

h = (
    Hist.new.Int(-5, 5, name="S", label="s [units]", flow=False)
    .Int(-5, 5, name="W", label="w [units]", flow=False)
    .Double()
)

np.random.seed(42)
s_data = np.random.normal(loc=1, size=100_000)
w_data = np.random.normal(size=100_000)

# normal fill
h.fill(s_data, w_data)

fig = plt.figure(figsize=(8, 8))
fig.suptitle("This is a plot", fontsize=16)

h.plot2d_full()

plt.show()

Now I'm not sure why the right counts tick labels (which I think doesn't have anything to do with the Int-Int main plot?) is all smashed into one spot. That's possibly buggy. Actually, filling this with doubles looks buggy too, will investigate.

@lfarinaa
Copy link
Author

lfarinaa commented May 5, 2023

Thanks for the tips.
Small update: the tick labels above "Counts" are the same tick labels in th y axis of the 2D plot, which is what is causing it to appear garbled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants