Auto set range of axis of a histogram

My question is about how to set automatically the range of Xaxis of a 1d histogram when creating a 1 d histogram? I understand when we could draw a leaf to a histogram from a tree, root can do it, say, automatically set the range. Okay, specially, I wanna draw a leaf in a tree (not by Draw method), but I don’t know max and min values in advance to determine a range. How will I do it? Until now, I didn’t find the key code in root to do that.


See documentation of class TH1 at

Histograms with automatic bins ============================== When an histogram is created with an axis lower limit greater or equal to its upper limit, the SetBuffer is automatically called with an argument fBufferSize equal to fgBufferSize (default value=1000). fgBufferSize may be reset via the static function TH1::SetDefaultBufferSize. The axis limits will be automatically computed when the buffer will be full or when the function BufferEmpty is called.


Thanks. I think this is only partially solove my problem. Okay, now I can get a proper range for Xaxis by using a larger low limit when defining a TH1. However, I also need to get automatically a bin size or bin numbers. I understand that once a TH1 is defined, we could not re-set a smaller bin size while we could re-set a larger bin size by using Rebin().