Rescale x axis of histogram

I have a histogram h1. At some point I realise that I want to rescale the x axis by some parameter a.
For that purpose I can create another histogram h2 as in the following example:

void rescale_axis()
{
  TH1F h1 = TH1F("angle", "angle", 10, 0.0, TMath::Pi());
   //...
   //Filling h1
   //...
  TH1F h2 = TH1F("angle/Pi", "angle/Pi", 10, 0.0, 1.0);
  for (unsigned char bind = 0; bind <= h1.GetNbinsX() + 1; bind ++)
    {
      h2.SetBinContent(bind, h1.GetBinContent(bind));
    }
}

Is there a way to do the rescale operation on h1 directly?


Please read tips for efficient and successful posting and posting code

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


1 Like

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