Plotting saved canvases in a canvas

Hi there,
Here’s my problem. I’d like to plot canvases saved in a TFile into a big canvas to compare them. Here are the kind of canvases I’m saving:

TCanvas c = new TCanvas(“c”,“c”) ;
c->Divide(2,2) ;
h = new TH1F (“h”,“h”,100,-10.,10.) ;
for (Int_t i=0; i<4; i++)
{ c->cd(i+1) ; h->FillRandom(“landau”,10**i) ; h->DrawCopy() ; }
TFile* f = new TFile (“canvas1.root”,“recreate”) ;
c->Write() ;
f->Close() ;

And here’s what I’d like to do:

TPad *p1=NULL, p2=NULL ;
TFile f=NULL ;
f = new TFile (“canvas1.root”,“read”) ; p1 = (TPad
)f->Get(“c”) ; f->Close() ;
f = new TFile (“canvas2.root”,“read”) ; p2 = (TPad
)f->Get(“c”) ; f->Close() ;
TCanvas *c_ = new TCanvas (“c_”,“c_”,10,10,1000,800) ;
p1->SetPad(.05,.05,.45,.95) ; p1->Draw() ;
p2->SetPad(.55,.05,.95,.95) ; p2->Draw() ;

But I only get the last pad drawn in my original “c” canvas and not in my new “c_” canvas.

Thanks for your help!
Regards, Zesp

In your second program you can do something like:

TCanvas *cnew = new TCanvas("cnew"); cnew->Divide(2,1); TFile *f; TCanvas *c; f = new TFile("canvas1.root"); c = (TCanvas*)f->Get("c"); c->Draw(); cnew->cd(1); c->DrawClonePad(); delete c; delete f; f = new TFile("canvas2.root"); c = (TCanvas*)f->Get("c"); c->Draw(); cnew->cd(2); c->DrawClonePad(); delete c; delete f;

We will try to simplify this procedure


Brilliant! Thanks for the fast answer :smiley: