I read this topic : “Merge more than one canvas in one”
and i modified my code:
{
TCanvas *C = new TCanvas("C", "Main Canvas", 960, 1100);
C->Divide(1,3);
TCanvas *c1 = new TCanvas ("c1", "Distribuzione random gaus", 700, 500);
TCanvas *c2 = new TCanvas ("c2", "Distribuzione random lineare", 700, 500);
TCanvas *c3 = new TCanvas ("c3", "Distribuzione random landau", 700, 500);
TFile *f= new TFile ("esercizio_esame.root", "recreate");
TH1D *h_1 = new TH1D ("Istogramma Gauss", "Distribuzione random Gaus", 100, -20, -20);
gRandom = new TRandom1();
for(Int_t i=0; i<10000; i++){
h_1->Fill(gRandom->Gaus(5,3));
}
TF1 *g = h_1->GetFunction("gaus");
h_1->Fit("gaus");
c1->cd();
h_1->DrawCopy();
h_1->Write();
C->cd(1);
c1->DrawClonePad();
TH1D *h_2 = new TH1D ("Istogramma Lineare", "Distribuzione random Lineare", 200, 0, 200);
gRandom = new TRandom2();
for(Int_t i=0; i<100000; i++){
h_2->Fill(gRandom->Integer(200));
}
c2->cd();
h_2->DrawCopy();
h_2->Write();
C->cd(2);
c2->DrawClonePad();
TH1D *h_3 = new TH1D ("Istogramma Landau", "Distribuzione random Lineare", 50, 0, 80);
gRandom = new TRandom3();
for(Int_t i=0; i<100000; i++){
h_3->Fill(gRandom->Landau(2));
}
c3->cd();
h_3->DrawCopy();
h_3->Write();
C->cd(3);
c3->DrawClonePad();
f->Close();
}
Now I see 4, the 3 canvas that i created before (How can I un-draw them?) and the main canvas, but it was empty…