Re: [ROOT] histogram binning

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Aug 04 2000 - 22:58:00 MEST


Hi Jason,
You have a typo in your array declaration. You must separate the entries
by a comma.
To create an histogram with variable bin width, you can do:
  Float_t xbins[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20};
  TH1F *EFar = new TH1F("EFar","EFar title",11,xbins);

Rene Brun


On Fri, 4 Aug 2000, jrieger wrote:

> Hey all,
> 	I am a novice root user, and am struggling to make a histogram
> with variable bins.  What I am looking for is a histogram with range from
> 0-20, with bins of 1 from 1-8 and bins of 4 from 12-20.  This is the code
> that I tried:
> 
>   Float_t xbins[12] = {0. 1. 2. 3. 4. 5. 6. 7. 8. 12. 16. 20.};
>   EFar->GetXaxis()->Set(11,xbins);
> 
> And I recieved the following error message when I tried to fill and draw
> the histogram:
> 
> Error in <TAxis::TAxis::Set>: bins must be in increasing order
> Error in <TCanvas::Range>: illegal world coordinates range: x1=22.680000,
> y1=-0.038994, x2=-2.520000, y2=0.350950
> 
> Any ideas on what to do with this problem.  I would appreciate the help.
> -Jason
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET