Histograms superimposed in one pad


I am drawing several 1D histograms into one pad/canvas. If I am not careful to draw the histogram with the largest number of entries first, the pad/canvas will not be large enough in the y-axis to show the histograms exeeding this first range.

How can I in a automatic and easy way make ROOT recognize the largest bin-entry and set the axis range according to this?

My code is typically something like


but if h1 sets the canvas range, so if h3 exceeds this it is cut off…


see class THStack and examples in the tutorials/hist


Thank you, I will try that.


You should create a THstack use the option “nostack” to draw it.

Thank you for your replies!

THStack takes good care of the bin-height problem.

But now I would like to use things like


How do I do that with THStack?

you can use them in the individual histograms belonging to the stack.

Ok, great, thank you very much!


And, hopefully one last thing:

When using THSTack, I am adding histograms into this. But I also want to draw the separate histograms in the same canvas. The problem now is that since I have to draw THStack after the separate histograms it puts itself on the top of the other smaller histograms, and of course covers the smaller histograms.

Can I pull the THStack histogram to the back when I draw it?


I am not fully understanding in which order you are doing things but whatever you do you may end up with overlapping issues when you draw several objects in the same pad (THStack, histograms or whatever …) . When you have a lot of them you should play with the FillStyle. Use fill styles which allows to see the histograms behind (try interactively with the graphics editor and when you are happy with the result save it in a .C file to see what are the relevant commands). You can also draw the histograms as simple lines and use line attributes to differentiate them or you can draw them using markers etc … there is many solutions …