TGraph() empty Graph

I’m running my code, fill my histogram with data but I receive the following error:

Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.

Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10

Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.

Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10


ROOT Version: 6.14.02
Platform: Not Provided
Compiler: Not Provided


First make sure that you are able to draw anything at all:

root [0] TH1F *h = new TH1F("h", "h", 1, 0, 1); h->Draw();

It seems you filled your histogram with Inf or NaN values.
Do you have a small macro reproducing what you get ?

I do, I tried passing it through an if statement to check for that but it still didn’t work.

if (!(std::isnan(integral) or std::isinf(integral)))
            {      
                if (channel <=2400 )
                {
                uPlane.Fill((double)channel,(double)integral);
                }
                else if(channel >2400 && channel <=4800)
                {
                vPlane.Fill(channel,integral);
                 }
                else
                 {
                yPlane.Fill(channel,integral);
                  }
             }

but it still didnt work out very well

Why not also check that the x-axis value is neither an Inf nor a NaN? Something like

if (!(std::isnan(integral) or std::isinf(integral) or std::isnan(channel) or std::isinf(channel)))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.