Re: [ROOT] Supermpose Histos with offset

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jul 09 2003 - 12:55:13 MEST


Hi Alessio,
 see example below

Rene Brun


void shift() {
   TH1F *h1 = new TH1F("h1","test",40,-2,2);
   h1->FillRandom("gaus",1000);
   TH1F *h2 = (TH1F*)h1->Clone("h2");
   TF1 *f1 = new TF1("f1","1+0.1*x",-2,2);
   h2->Multiply(f1,1);
   h1->SetMarkerStyle(20);
   h1->SetMarkerColor(kBlue);
   Double_t shift = 0.5*h1->GetBinWidth(1);
   h2->GetXaxis()->SetLimits(-2+shift,2+shift);
   h2->SetMarkerStyle(21);
   h2->SetMarkerColor(kRed);
   h1->Draw("e1");
   h2->Draw("e1 same");
}
   

Alessio Sarti wrote:
> 
> Hi all,
> I'd like to superimpose two histograms that have the same range with
> markers a little bit displaced.
> To clarify:
> root puts by default a marker at a center of the bin. I want to draw an
> histogram with a marker that is not placed at the center but a little bit
> displaced (right or left is not a problem). In this way I avoid error bars
> of my superimposed histos to overlap/merge and the plots is more readable.
> 
> There's a given function/macro that can do that?
> Thanks very very much.
> Alessio
> 
> ______________________________________________________
> Alessio Sarti     Universita' & I.N.F.N. Ferrara
> 
> >>>I'm in Ferrara<<<
> 
>  tel  +39-0532-974328  Ferrara
> roma  +39-06-49914338
> SLAC +001-650-926-2972
> 
> "... e a un Dio 'fatti il culo' non credere mai..."
> (F. De Andre')
> 
> "He was turning over in his mind an intresting new concept in
> Thau-dimensional physics which unified time, space, magnetism, gravity
> and, for some reason, broccoli".  (T. Pratchett: "Pyramids")



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET