Show units for colour bar

Let us consider an example at https://root.cern/doc/master/classTHistPainter.html

{
   auto c1    = new TCanvas("c1","c1",600,400);
   auto hcol1 = new TH2F("hcol1","Option COLor example ",40,-4,4,40,-20,20);
   float px, py;
   for (Int_t i = 0; i < 25000; i++) {
      gRandom->Rannor(px,py);
      hcol1->Fill(px,5*py);
   }
   hcol1->Draw("COLZ");
}

Could you please remind how to show the units for the colour bar?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


{
   auto c1    = new TCanvas("c1","c1",600,400);
   auto hcol1 = new TH2F("hcol1","Option COLor example ",40,-4,4,40,-20,20);
   float px, py;
   for (Int_t i = 0; i < 25000; i++) {
      gRandom->Rannor(px,py);
      hcol1->Fill(px,5*py);
   }
   hcol1->Draw("COLZ");
   hcol1->GetZaxis()->SetTitle("units");
}

1 Like

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