Draw a subpad in a new Canvas

Hello rooters,
I take a canvas AllCanvas, divide it into 12 subcanvas and paint several graphs and histograms into these subcanvas. Then I would like to get one
graph or histogram out and draw it into a new TCanvas, which does not work properly.

My code:

TCanvas* AllCanvas = new TCanvas(“AllCanvas”,“All plots”, 50, 10, 1400,700);

AllCanvas->Divide(6,2);
AllCanvas->cd(1);
GT0_Rayleight->Draw(“A*”);

AllCanvas->cd(2);
GLineChiSquare->Draw(“C”);

… up to …

AllCanvas->cd(12);
HH->Draw();

That works. Then:

TCanvas Ctest =new TCanvas(“Ctest”,“Ctest”,10,20,600,400);
TPad
SelectedCanvas;
SelectedCanvas=(TPad*)((TPad*)AllCanvas->GetPad(CanvNumb))->Clone());

where CanvNumb is between 1 and 12. When I now want to draw this SelectedCanvas:

Ctest->cd(0);
SelectedCanvas->Draw();

then it keeps the size of the original subcanvas and I have to resize it with the mouse. Is it possible to do this automatically?

You should simply do:
TCanvas *Ctest =new TCanvas(“Ctest”,“Ctest”,10,20,600,400);
AllCanvas->GetPad(CanvNumb))->DrawClone();

You can also it interactively.
-Create your new canvas
-With the mouse go to the source pad and select DrawClone
in the context menu.

Rene

Thanks for your answer!
Still it is quite strange, that in the new Canvas the cloned Canvas does not take the whole size, but it is in the same space as it was before (see attachments)!



If you want the clone to occupy the full range of the canvas, do
mypad->SetPad(0,0,1,1)

Rene