How to get the y-axis range of a histogram as set by Draw


I am having trouble to identify how exactly is calculated the plotted x & y range of a histogram when “Draw” is invoked.

If one uses Draw for one histogram, and then Draw(“same”) for a second histogram that happens to have a wider y-axis range than the first histogram, then the second histogram is clipped off in the plot.

I would ike to get the maximum value in the plotted range of the y-axis of the first histogram, set the plotted range of y-axis of the second histogram to that value (with SetRangeUser?) and then Draw(“same”) the second histogram to superpose it on the first histogram.

I haven’t been able to figure out how to retrieve the y-axis range of the first histogram as set by Draw, and then use that for the second histogram. I would have thought this value is


which seems to work from a CINT window but returns 1 from inside a macro.

What is the best sequence of commands to do this?



Instead of using the option “same” you should group the 2 histograms in a THStack and plot it with the option “nostack”. See:

OK, this would work for some cases, but can I also read off from the histogram or from the pad the scale set by “Draw”?

Is there a “Get” command for this?


Inside a macro you should issue a :


after the “Draw()” before doing: