RE: re-scaling a TGraph

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 15 Feb 2007 09:36:54 +0100


Hi,

The last change we did in TGraph should fix this issue: See the CVS log:
http://root.cern.ch/viewcvs/graf/src/TGraph.cxx This fix is in the last release (from yesterday).

Cheers, Olivier Couet

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch
[mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Roger Mason
Sent: Wednesday, February 14, 2007 7:32 PM To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] re-scaling a TGraph

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 Thu Feb 15 2007 - 09:37:03 CET

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