Hi,
I face a problem when drawing a variable bin size histo in log scale.
The last channel is not displayed correctly but is much larger than it should.
Below is an example where I just took a script given in the roottalk forum and
changed the minimum to show the phenomenon.
Can some one help ?
P. Sizun
{
const Int_t nbins = 100;
Double_t xmin = 1e-3;
Double_t xmax = 1e3;
Double_t logxmin = TMath::log10(xmin);
Double_t logxmax = TMath::log10(xmax);
Double_t binwidth = (logxmax-logxmin)/nbins;
Double_t xbins[nbins+1];
xbins[0] = xmin;
for (Int_t i=1;i<=nbins;i++) {
xbins[i] = xmin + TMath::Power(10,logxmin+i*binwidth);
}
TH1F *h = new TH1F("h","hist with log x axis",nbins,xbins);
Double_t x,xl;
for (Int_t j=0;j<10000;j++) {
xl = 0.5*(logxmin+logxmax) + 12*binwidth*gRandom->Gaus(0,1);
x = xmin + TMath::Power(10,xl);
h->Fill(x);
}
TCanvas *c1 = new TCanvas("c1");
c1->SetLogx();
h->SetMinimum(-200.0);
h->Draw();
}
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET