Hello,
I’m drawing several TH1 objects on the same TCanvas within a loop;
at each iteration a new histograms is drawn on the canvas, something
like this:
[code]vector fileNames;
TCanvas *c=new TCanvas(1);
c->Divide(1,2);
for(int i=0;i<fileNames.size();i++){
TFile *f=TFile::Open(v[i]);
TH1D *h=(TH1D*)f->Get("histo");
if(i==0){
c->cd(1);
h->Draw();
}
else {
c->cd(1);
h->Draw("same");
}
}
[/code]
the problem is that the length (ymax) of the y axis is set by the histogram drawn
at i=0, hence if one of the later histograms has a bin content greater than ymax
it is not drawn properly. I would like to use the SetRangeUser method in the code
(without having to do that from GUI after the code has been run): I’ve looked for
some methods for getting the TAxis object from the TCanvas in order to use the
SetRangeUser method, but haven’t been able to do it, no matter how many workarounds
I’ve tried. is there a way I can achieve this?
thanks in advance for any advice.
Salvatore