# Template for comparing 2 Histograms

Hello,

In order to compare 2 Histograms i’ve seen a Plot like the following many times

``` | ooooo | ox o |ox xxxx oooooooo |x xxxxxxxxxxxxx |________________________________ | ... | ... ....................... |._________________________________```

The upper Graph shows both Histos, while the lower Graph shows one Histo diveded by the other.

Is there a nice example Root code for that anywhere? I guess its not really complicated (i know how to divide histos), but quite some work to make it look good…

So if anyone has some code, that would be nice.

Thomas

You can use a transparent pad for the result of the division. See an example of transparent pad at \$ROOTSYS/tutorials/hist/transpad.C

Rene

Thx, that will help when I try to create it on my own, but i was hoping for a… well… easy solution

Use three hists and the “SAME” option for Draw method ?

No this will not work because the scales will be different

Rene

[quote]No this will not work because the scales will be different

Rene[/quote]

I mean if he looks for the simplest way, he can forget about his original idea and draw all three hists in one pad:

``````TH1D * h1 = new TH1D("The Bad", "Angel eyes", 2, -1., 1.);
h1->SetBinContent(1, 10);
h1->SetBinContent(2, 20);
h1->SetMinimum(0.);
h1->SetFillColor(kRed);
TH1D * h2 = new TH1D("The Ugly", "Tuco", 2, -1., 1.);
h2->SetBinContent(1, 5.);
h2->SetBinContent(2, 4.);
h2->SetFillColor(kGreen);
TH1D * h3 = new TH1D("The good", "Blondie", 2, -1., 1.);
h3->Divide(h1, h2);
h1->Draw();
h2->Draw("same");
h3->Draw("same");``````