Incorrect binning of Integer parameter in 2D histogram

Dear Rooters,

I want to plot a real (floating) variable against an integer parameter using the 2D histogram constructor. My script essentially generates a series of histograms from a root file (created using the TTree constructor).

The problem I have is that the resulting plot bins the integer parameter as a float. When plotting direct from TTree no problem. See below.

Example of plot direct from the TTree. This is what it should look like.

The same plot after dumping the parameters into a 2D histogram and plotting. The data points should be binned at integer intervals along the x-axis.

I’d be grateful for any help on a work around. I’ve tried TH2I as opposed to TH2F…same result. The other thing i thought of is perhaps how I’ve declared the variables. In the TTree preamble I’ve declared the variables in the form:


while in preamble of the script that reads the rootfile to generate the histograms, I declare the variables in the form:


Is there a way to explicitly declare parameters in histograms as floats or integers?

Many thanks

I would recommend when you plot the histogram to not use the scatter plot default option but COL or BOX for instance.

Many thanks. While I think it would be preferable to have marker points such as used with scatter plots, your proposed solution will suffice.

Thanks once again.

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