Superposing two histograms

this is surely a rather basic question, but…
does ROOT provide a simple method for resizing the y axis if we plot two histograms such that both are icontained in the same y-range?

say, i do:
h1.Draw()
h2.Draw(“SAME”)

Can ROOT automatically resize the Canvas such that h1, and h2 are both contained in the same range?
i can of course either:

  • compare h1.GetMaximum() and h2.GetMaximum() and plot h1 or h2 first accordingly

Two ways:

  1. Draw a frame wide enough using c->DrawFrame(…) (c is a canvas) and draw the 2 histograms using the option “same”

  2. Use a THStack as described here: root.cern.ch/root/html/THistPainter.html#HP26

i’m aware of these approaches Olivier. I mean some option such that i don’t need to bother, either resizing the pad or checking the max for both histograms.
rephrasing my question: does the Draw option provide an option like ‘R’ which automatically resizes the pad, if an histogram h1 is already drawn such that h1 and h2 then fit in the same pad ,

does this option ‘R’ exist?

Use a THStack, see examples in the tutorials and this simple example below

Rene

void hs() { TH1F *h1 = new TH1F("h1","test1",100,-4,3); h1->FillRandom("gaus",10000); TH1F *h2 = new TH1F("h2","test2",100,-3,4); h2->FillRandom("gaus",10000); THStack *hs = new THStack("hs","stack example"); hs->Add(h1); hs->Add(h2); hs->Draw("nostack"); }