Re: [ROOT] (no subject)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 11 2004 - 13:42:54 MEST


An example below. Change the algorithm as you like for the color allocation.

Rene Brun

void barcols() {
   const Int_t nbins = 60;
   TH1F *h = new TH1F("h","test",nbins,-2,2);
   h->FillRandom("gaus",1000);
   h->DrawCopy("a");  //draw only the axis
   gStyle->SetPalette(1,0);
   Int_t bin = 1;
   Int_t color = 30;
   while (bin <nbins) {
      Int_t bin2 = bin + (Int_t)3*gRandom->Rndm();
      h->GetXaxis()->SetRange(bin,bin2);
      h->SetFillColor(color++);
      h->DrawCopy("bar2 same");
      bin = bin2+1;
      if (color >= 50) color=30;
   }
}


Angela Re wrote:
> 
> Good morning, I have a question : how can I fill with different colours
> the histogram's bars?
> Thank you. Angela Re.



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET