Change color level

Dear Rooters,

I am attaching a macro (given in the root site)
I want to change 0 level to white instead of blue of the contour drawn on top (with no front and back box).

Any help?

{
   TCanvas *c2 = new TCanvas("c2","c2",600,400);
   gStyle->SetPalette(kBird);
   TH2F *hsurf3 = new TH2F("hsurf3","Option SURF3 example ",30,-4,4,30,-20,20);
   Float_t px, py;
   for (Int_t i = 0; i < 25000; i++) {
      gRandom->Rannor(px,py);
      hsurf3->Fill(px-1,5*py);
      hsurf3->Fill(2+0.5*px,2*py-10.,0.1);
   }
//   fit1->SetContourLevel(0,0.1); //Change 0 level to white instead of blue
   hsurf3->Draw("SURF3 FB BB");
   return c2;
}

Hi,

Possible solution can be usage of custom contour array, which does not include zero values.
Like here:

{
   TCanvas *c2 = new TCanvas("c2","c2",600,400);
   gStyle->SetPalette(kBird);
   TH2F *hsurf3 = new TH2F("hsurf3","Option SURF3 example ",30,-4,4,30,-20,20);
   Float_t px, py;
   for (Int_t i = 0; i < 25000; i++) {
      gRandom->Rannor(px,py);
      hsurf3->Fill(px-1,5*py);
      hsurf3->Fill(2+0.5*px,2*py-10.,0.1);
   }

   double max = hsurf3->GetMaximum();
   const int num = 20;
   Double_t contours[num];
   for (int n=0;n<num;n++)
      contours[n] = max/num*(n+1);
   hsurf3->SetContour(num, contours);

   // fit1->SetContourLevel(0,0.1); //Change 0 level to white instead of blue
   hsurf3->Draw("SURF3 FB BB");
   return c2;
}

Will produce image:
c2

1 Like

that’s nice…thank you very much linev

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