[ROOT] Drawing multiple histograms together

From: Chris Milne (phycm@phy.hw.ac.uk)
Date: Fri Sep 07 2001 - 15:42:01 MEST


Hi there, 

I have the following code to draw a number of histograms on one pad:

     Int_t biny = h2->GetYaxis()->FindBin(y2);	//get bin from previous mouse 
coord
     if (hp)   delete hp;
     if (hps)  delete hps;
     if (hpol) delete hpol;
     if (hpsl) delete hpsl;
     if (hpl)  delete hpl;
     if (hpa ) delete hpa;
     if (show_OCP==1)
       hp = h2->ProjectionX("OCP",biny,biny);	//create OCP slice
     if (show_SCP==1)
       hps = h3->ProjectionX("SCP",biny,biny);	//create SCP slice
     if (show_OLP==1)
       hpol = h5->ProjectionX("OLP",biny,biny);//create OLP slice
     if (show_SLP==1)
       hpsl = h6->ProjectionX("SLP",biny,biny);//create SLP slice
     if (show_linear==1)
       hpl = h4->ProjectionX("Linear",biny,biny);	//create linear slice
     hpa = h4->ProjectionX("hpa",biny,biny);	//create axis
     char title[80];
     if (selection2==('o'||'O'))
       sprintf(title,"Optical Density at Time=%3.3f ps",y2);	//set titles
     else
       sprintf(title,"Differential Transmission at Time=%3.2f ps",y2);
     hpa->SetTitle(title);
     hpa->GetXaxis()->SetTitle("Energy (meV)");
     if (selection2==('o'||'O'))
       hpa->GetYaxis()->SetTitle("Optical Density");
     else
       hpa->GetYaxis()->SetTitle("Differential Transmission");
     hpa->GetXaxis()->SetRange(binmin,binmax);       
     hpa->GetXaxis()->CenterTitle();
     hpa->GetYaxis()->CenterTitle();
     hpa->SetLineColor(48);
     hpa->Draw("L");
     if (show_linear==1)
     {
       hpl->Draw("same");
     }
     if (show_OCP==1)
     {
       hp->SetLineColor(kGreen);
       hp->Draw("same");
     }
     if (show_SCP==1)
     {
       hps->SetLineColor(kBlue);
       hps->Draw("same");
     }
     if (show_OLP==1)
     {
       hpol->SetLineColor(kRed);
       hpol->Draw("same");
     }
     if (show_SLP==1)
     {
       hpsl->SetLineColor(kYellow);
       hpsl->Draw("same");
     }
     pad7->cd();
     draw_legend();
     if (point) delete point;
     
This works fine, however I want all the histograms to be drawn with option "L", 
so I tried "Lsame" and got the following:

Fatal in <operator delete>: storage area overwritten
aborting

but if I just try "L" only the last histogram is displayed! Any ideas?

Thanks in advance
Chris Milne



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET