I have a file with histograms. On some of them I get this error when I try to draw them:
root  h->Draw()
Warning in TCanvas::ResizePad: Inf/NaN propagated to the pad. Check drawn objects.
Warning in TCanvas::ResizePad: c1 height changed from 0 to 10
I guess this error has something to do with the histrogram trying to set the height of the pad to a NaN or Inf value and so the height is set to a default range.
I looking for insight as to what is the source of this error. I guess there must have been some error in filling the histogram - perhaps a Nan value was filled? When I examine the bin content, and mean of the histogram the data look reasonable.
I’m also interested in how I might be able to detect this error without having to try to draw the histogram. Is there some histogram method I can put in a script which would return some error value if there is some problem with the histogram such that it cannot be drawn?
Could you do:
This will print the bin contents. It is likely that at least one bin contains a NaN.
I do not see any Nans from h->Print(“all”). The the values are integers. I assume a Nan would show up as “nan” or similar.
Could you send/post a small ROOT file containing your histogram ?
I have attached a file with a bad histogram in it - has nan’s somewhere so that it will not plot.
I’d like to know where the nan’s are and how to detect them (in a root script).
nan_hist.root (6.95 KB)
Your histogram has a TF1 object inamed “TimeSpectrum” n its list of functions.
This TF1 has parameters that are NaN.
You can do
to reset these parameters.
Up to you to find out what you did with this function.
Thanks for finding my problem. Obviously, the program which generates these histograms should not be filling them with nan’s. I will have to fix that.