Re: [ROOT] Show histograms in one figure

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu May 02 2002 - 18:00:39 MEST


Hi Ingo,

See example below

Rene

// example of script showing how to divide a canvas
// into adjacent subpads + axis labels on the top and right side
// of the pads.
{
   gROOT->Reset();
   TCanvas c1("c1","multipads",900,700);
   gStyle->SetPadBorderMode(0);
   gStyle->SetOptStat(0);
   c1.Divide(2,2,0,0);
   TH2F h1("h1","test1",10,0,10,20,-0.4,1.6);
   TH2F h2("h2","test2",10,0,10,20,0,200);
   TH2F h3("h3","test3",10,0,10,20,-0.4,1.6);
   TH2F h4("h4","test4",10,0,10,20,0,200);

   c1.cd(1);
   gPad->SetBottomMargin(0);
   gPad->SetRightMargin(0);
   gPad->SetTickx(2);
   h1.Draw();
   TF1 f1("f1","sin(x)/x",0,10);
   f1.Draw("lsame");
   
   c1.cd(2);
   gPad->SetLeftMargin(0);
   gPad->SetBottomMargin(0);
   gPad->SetTickx(2);
   gPad->SetTicky(2);
   h2.GetYaxis()->SetLabelOffset(0.01);
   h2.Draw();
   TF1 f2("f2","1+x+x*x",0,10);
   f2.Draw("lsame");
   
   c1.cd(3);
   gPad->SetTopMargin(0);
   gPad->SetRightMargin(0);
   h3.Draw();
   TF1 f3("f3","sin(1.5*x)/x",0,10);
   f3.Draw("lsame");

   c1.cd(4);
   gPad->SetLeftMargin(0);
   gPad->SetTopMargin(0);
   gPad->SetTicky(2);
   h4.Draw();
   TF1 f4("f4","1+x+1.6*x*x",0,10);
   f4.Draw("lsame");
}      


On Thu, 2 May 2002, Ingo Froehlich wrote:

> Hello,
> 
> maybe it already hidden in the tutorials, because it is a standard
> procedure... But how can I show 2 (or more) histograms so that they are
> placed in the same figure:
> 
> L +-------+
> A |       |
> B |       |
> E |       |
> L |       |
> 1 |       |
>   +-------+
> L |       |
> A |       |
> B |       |
> E |       |
> L |       |
> 2 +-------+
>      LABELX
> 
> Best Regards, Ingo
> 
> -- 
> Ingo Froehlich, II. Physikalisches Institut, Universitaet Giessen
> Heinrich-Buff-Ring 16, D-35392 Giessen           |  Tel.: 0641 - 99 33250
> EMail: Ingo.Froehlich@exp2.physik.uni-giessen.de |  Fax : 0641 - 99 33239
> Sekretariat: 0641 - 99 33241                     |                    :-)
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET