How to define a smooth color palette ?

TColor::CreateGradientColorTable(..) provides this functionnality:

{
   TCanvas *c  = new TCanvas("c","Contours",600,0,600,600);
   TF2 *f1 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
   UInt_t Number = 3;
   Double_t Red[Number]    = { 1.00, 0.00, 0.00};
   Double_t Green[Number]  = { 0.00, 1.00, 0.00};
   Double_t Blue[Number]   = { 1.00, 0.00, 1.00};
   Double_t Length[Number] = { 0.00, 0.50, 1.00 };
   Int_t nb=50;
   TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
   f2->SetContour(nb);
   f2->Draw("surf1z");
}

TColor::CreateGradientColorTable(..) creates a linear gradient color table. Red, Green and Blue are several RGB colors with values from 0.0 .. 1.0. They define "intervals". The whole gradient goes from 0.0 for the first RGB color to 1.0 for the last RGB color, then each "Length"-entry in between defines the position of the corresponding RGB colors. This definition is similar to the povray-definition of gradient color tables. In order to create a color table do the following: Define the RGB Colors:

   UInt_t Number = 5;
   Double_t Red[5]   = { 0.00, 0.09, 0.18, 0.09, 0.00 };
   Double_t Green[5] = { 0.01, 0.02, 0.39, 0.68, 0.97 };
   Double_t Blue[5]  = { 0.17, 0.39, 0.62, 0.79, 0.97 };
Define the length of the (color)-interval between this points:
   Double_t Length[5] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
i.e. the color interval between Color 2 and Color 3 is 0.79 - 0.62 => 17 % of the total palette area between these colors.

See also the article about the rainbow color map.