calbet
October 19, 2015, 2:17pm
1
Dear experts,
when I try to draw several hist in different canvas pad in a for loop, I end up with 1 canvas, do you know why? For ex in [*], while if I do it outside of a loop, it works[**].
Regards,
[*]
void plot(){
…
TCanvas *c = new TCanvas(“c”, “”, 1000, 700);
c->Divide(4,2);
for(int i=0; i<4; i++){
c->cd(i);
hist->Draw();
}
}
[**]
void plot(){
…
TCanvas *c = new TCanvas(“c”, “”, 1000, 700);
c->Divide(4,2);
c->cd(0);
hist->Draw();
c->cd(1);
hist->Draw();
…
}
Hi,
Weird… Which version of ROOT, which OS/compiler?
And does $(ROOTSYS)/tutorials/hist/hksimple.C work? (it does more or less the same)
Cheers, Bertrand.
for(int i = 1; i <= 4; i++){
couet
October 19, 2015, 4:04pm
4
when you do
c->Divide(4,2);
you create 4x2 = 8 pads numbered from 1 to 8
this loops draws in pads number 0,1,2,3
for (int i=0; i<4; i++) {
c->cd(i);
hist->Draw();
}
as Wile pointed you should start at number 1 … and you can loop up to 8.
calbet
October 20, 2015, 9:26am
5
Dear experts,
thanks you, actually I should start at “1” and not “0”.
Regards