Hi Thomas,
I suggest to use a variable bin size histogram as shown in the example below.
Rene Brun
void logaxis()
{
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->Draw();
}
Thomas Bretz wrote:
>
> Hello rooters,
>
> I have a histogram which is filled with some data. The get a more
> conviniet view of the x-axis I set the bins of the histogram so, that if
> I call gPad->SetLogx() I get equidistant bins. Now I want to fit this
> view with a gaussian, but TH1::Fit fits the original data instead of the
> logarithmic data.
>
> Is it possible to get either the nice view of a log-scaled X-Axis if i
> would use equidistant bins and fill the histogram with log(data) or is
> it possible to tell the fitter, that it should fit the logarithmic data
> instead of the 'real' data in the histogram?
>
> Thanks,
> Thomas.
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET