Hello,
I’m drawing several TCanvas with few histograms in a loop which (depending on a variable) draw each histogram in a specific canvas. I don’t know (until the end of the loop) how many histograms goes in each canvas so I don’t know what would be the correct size for the TLegend box. Is there any command to change (after the creation of the TLegend) the legend box?
Code example:
TCanvas *cMdistMass[5];
TLegend *legMass[5];
for(int n=0;n<5;n++) {
legMass[n] = new TLegend(0.50,0.70,0.88,0.84);
cMdistMass[n] = new TCanvas(Form("cMdistMass_%d",n),"",0,0,800,800);
}
for(int n=0;n<20;n++) {
...
indxMass = "this is an integer between 0 and 4"
cMdistMass[indxMass]->cd();
aHisto->Draw("same");
legMass[indxMass]->AddEntry(aHisto,"...","LEP");
...
}
So in each of the 5 canvas I get 3,4,5, or 6 histograms and the legend should have different dimensions… I could easily solve the problem running twice the loop but I was wondering if I could change the dimension (i.e. the value of the 4 numbers used in the legend ctor) at the end of the loop.
Thanks
Attilio