Histogram from Ttree produces a blank plot

I’m trying to plot a histogram of two Tree objects using this code snippet

TH2F *h2 = new TH2F("","",100,1195,1275,100,400,500)
Treename->Draw(fvar1:fvar2>>h2","","goff")
h2->Draw("colz")

But the resultant histogram is a blank plot. but whenever I plot
Treename->Draw(fvar1:fvar2","",“colz”)
it gives me a plot I expected so I know it is not blank. Any reason why I could be getting a blank plot using the earlier snippet. The reason I used the earlier snippet was to get finner binning in my plot and plotting tree objects as histograms was the easiest way for me.


ROOT Version: 6.16.00
Platform: LinuxMInt
Compiler: Not Provided


Solved it.
For someone stumbling up here later, this is what I did

TH2F *h2 = new TH2F("h2","h2",100,1195,1275,100,400,500); // name (h2) here 
Treename->Draw("fvar1:fvar2>>h2","","goff"); // and here needed to match
h2->Draw("colz")

Thanks for sharing the answer!

you should name the histogram:

TH2F *h2 = new TH2F("h2","h2",100,1195,1275,100,400,500)
1 Like

Thank you.

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