re-scaling a TGraph

From: Roger Mason <rmason_at_esd.mun.ca>
Date: Wed, 14 Feb 2007 15:01:50 -0330


Hello rooters,

root 5.14/00 gentoo-2.6.18-r6 gcc 4.1.1

I need to modify the values in the y array of a TGraph then have the graph updated on the current canvas. The following code fragment changes y values in a specified range. However, when graph->Update() does not re-scale the axes, so the modified points may be off-scale when the canvas is updated.:

[snip]

  Double_t x,y;
  for (int i = 0; i < fGraph->GetN(); i++){     fGraph->GetPoint(i, x, y);
    if (x >= fRegionMin && x <= fRegionMax){

      //  cout << "Point 0 x = " << x << " y = " << y << endl;
      y = y * fJump;
      fGraph->SetPoint(i, x, y);

    }
  }
  TCanvas *fCanvas = fEcanvas->GetCanvas();   fCanvas->Draw("AP");
  Double_t maximum = fGraph->GetHistogram()->GetMaximum();   cout << "Max Y = " << maximum << endl; // Returns old maximum :-(
  fCanvas->Update();                     // Y scale not updated

[snip]

How do I cause the y axis to be re-scaled?

Thanks,

Roger Received on Wed Feb 14 2007 - 19:32:22 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 15 2007 - 11:50:01 CET