[BUG] plot2d_full does not work properly on Int axes
lfarinaa opened this issue · comments
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()
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.
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.