Update of range of a graph

ROHLFS Reiner (Reiner.Rohlfs@obs.unige.ch)
Fri, 07 Nov 1997 14:55:43 +0100 (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();

}