Home | News | Documentation | Download

I need to plot 2 histograms for multiplicity in a single plot. I need it in the form of a bar chart.( 1 histogram adjacent to another)

_ROOT Version:_6.20/04

So I have already consulted the page on vertical bar charts. But it’s very confusing. Say h1 and h2 are my 2 histograms. I gave my command as below, but nothing changed. The second histogram was superimposed on the first one.

     h1->Draw ("bar2");
     h2 ->  Draw ("bar2, same");

Any help would be much appreciated.


{
   h1 = new TH1F("h1","h1",10,-3,3);
   h1->FillRandom("gaus",10000);
   h1->SetBarWidth(0.5);
   h1->SetBarOffset(0.);
   h1->SetFillColor(kRed);
   h1->Draw("hbar2");

   h2 = new TH1F("h2","h2",10,-3,3);
   h2->FillRandom("gaus",10000);
   h2->SetBarWidth(0.5);
   h2->SetBarOffset(0.5);
   h2->SetFillColor(kBlue);
   h2->Draw("hbar2 same");

}

Thank you so much.