Re: [ROOT] ncolors and Draw("colz")

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Oct 29 2002 - 23:08:16 MET


Hi Alexandr,

You must set the number of contours in your TH2.
See your example below modified to generate 58 colors and the
corresponding 58 contours.

{
  const Int_t colNum = 58;  
  TH2S *h = new TH2S("h", "h", 10, 1, colNum, 10, 1, colNum);

  Int_t palette[colNum];
  for (Int_t i=0;i<colNum;i++) {
    TColor *color = new TColor(301+i,
                               pow(i/((colNum)*1.0),0.3),
                               pow(i/((colNum)*1.0),0.3),
                               0.5*(i/((colNum)*1.0)),"");
    palette[i] = 301+i;
  }
  h->SetMinimum(1);
  h->SetMaximum(colNum);
  h->SetContour(colNum);
  gStyle->SetPalette(colNum,palette);
  h->Draw("colz");
}


Rene Brun


On 29 Oct 2002, Alexandr Malusek wrote:

> Hi,
> 
> I have a problem with setting the number of palette colors when the
> "colz" option is used with TH2. In the past, the following code set 32
> colors but now only 20 colors are displayed on the color bar.
> 
> // A palette problem
> {
>   const Int_t colNum = 32;  
>   TH2S *h = new TH2S("h", "h", 10, 1, colNum, 10, 1, colNum);
> 
>   Int_t palette[colNum];
>   for (Int_t i=0;i<colNum;i++) {
>     TColor *color = new TColor(301+i,
> 			       pow(i/((colNum)*1.0),0.3),
> 			       pow(i/((colNum)*1.0),0.3),
> 			       0.5*(i/((colNum)*1.0)),"");
>     palette[i] = 301+i;
>   }
>   h->SetMinimum(1);
>   h->SetMaximum(colNum);
>   gStyle->SetPalette(colNum,palette);
>   h->Draw("colz");
> }
> 
> I need 58 colors to distinguish tissues in some low resolution medical
> images. How can I do it?
> 
> --
> Alexandr.Malusek@imv.liu.se
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:16 MET