I have created a 2D histogram for an ADC signal. On the x-axis I have a time bin, and on the y-axis I have voltage.

The time-bin is always an integer. I have made a histogram with bins that are equal to the value of each time bin. So, for a given bin, they should all have exactly the same x-value, and differing y-values.

But when I plot the histogram, I get a distribution of x-values. Can anyone explain to me why this is happening?

The “scatter” drawing for TH2 histograms is actually misleading. Each point drawn does not correspond to a count in that bin. Instead it draws points randomly inside each bin, and the number is equal to the content of the bin, but the locations of the points are random. I think it does this for speed reasons, but in the end what you get is NOT a scatter plot of your data. Drawing a TH2 with the other drawing options like “colz” makes a representation that doesn’t use random variables.

If you need a real scatter plot, make a TGraph instead. Then each point drawn is indeed a data point and you’ll see your X values line up with the integer ticks.

[quote=“jfcaron”]The “scatter” drawing for TH2 histograms is actually misleading. Each point drawn does not correspond to a count in that bin. Instead it draws points randomly inside each bin, and the number is equal to the content of the bin, but the locations of the points are random. I think it does this for speed reasons, but in the end what you get is NOT a scatter plot of your data. Drawing a TH2 with the other drawing options like “colz” makes a representation that doesn’t use random variables.

If you need a real scatter plot, make a TGraph instead. Then each point drawn is indeed a data point and you’ll see your X values line up with the integer ticks.