How to set the first color of the colorbar to white

In the 2D histogram, I have used colorbar and set the Palette to “kRainBow”, I would like to know how to change the first colour in “kRainBow” to white

  hist->Draw("COLZ");
  gPad->Update();

   Double_t value = hist->GetMinimum();
   Int_t index = hist->GetListOfFunctions()->FindObject("palette")->GetValueColor(value);

   TColor *color= gROOT->GetColor(index);
   color->SetRGB(1., 1., 1.,);
   gPad->Update();

Thank you for your reply. After I run it, “no member named ‘GetValueColor ()’” is displayed. How to solve it?

void getvaluecolor2() {

   TH2D* hist  = new TH2D("hist", "", 20, -5, 5, 20, -5, 5);

   for(int i = 0; i < 100; i++){
      double x = gRandom->Gaus();
      double y = gRandom->Gaus();
      hist->Fill(x, y);
   }

   hist->Draw("COLZ");
   hist->SetStats(0);

   gPad->Update();

   TPaletteAxis *palette = (TPaletteAxis*)hist->GetListOfFunctions()->FindObject("palette");
   Int_t index           = palette->GetValueColor(hist->GetMinimum());
   TColor *color         = gROOT->GetColor(index);
   color->SetRGB(1., 1., 1.);

   gPad->Modified();
   gPad->Update();
}

gives:

The problem has been solved. Thank you very much for your reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.