Update of range of a graph

From: ROHLFS Reiner (Reiner.Rohlfs@obs.unige.ch)
Date: Fri Nov 07 1997 - 14:55:43 MET


Hi Rooters,

is there a possibility to update the range of the graph after the position of a
point has changed? I tried it with following macro, but it doesn't work. The
point number 2 is skipped now and the range of the Y axis does not change as I
expected reading the documentation. 

Cheers Reiner.


{
  gROOT->Reset();

  Float_t x1, y1, x2, y2;
 
// Create a new canvas.
   c1 = new TCanvas("c1","canvas",50,10,600,300);

// crate a pad
   pad = new TPad("p1", "pad", 0.05, 0.05, 0.95, 0.95); 
   pad->SetFillColor(17);
   pad->Draw();

// draw a graph
   pad->cd();

   Float_t x[] = {8., 10., 13., 14., 16.};
   Float_t y[] = {1.2, 1.8, 6., 4., 4.};

   TGraph * graph = new TGraph(5, x, y);
   graph->Draw("AL");

   c1->Update();

// now change a point and update range of axis
   graph->SetPoint(2, 13., 8.);
   pad->GetRangeAxis(x1, y1, x2, y2);
   pad->RangeAxis(x1, y1, x2, y2 + 2);
   pad->Modified();
   c1->Update();

}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET