[ROOT] automatic update of axis range while looping over TGraphs

From: Dirk Meier (Dirk.Meier@cern.ch)
Date: Sun Jul 08 2001 - 22:34:57 MEST


Hi,

the program below draws TGraphs in two TPads.
The contents of the TGraphs changes inside a loop
and I would like to display the new TGraphs 
after each change.

The problem is that the axis range does not
update automatically.

How could I implement  automatic update of axis
ranges ?

best regards
Dirk Meier


//
{
  gROOT->Reset();

  TCanvas *c = new TCanvas("c","canvas bla",500,300);;

  TList *gList = new TList();

  for(Int_t pk = 1; pk<=2; pk++) {
    gList->Add( new TGraph(3) );
  }
  
  c->Divide(2,1);  

  c->cd(1);
  gList->At(0)->Draw("AL*");
  c->cd(2);
  gList->At(1)->Draw("AL*");
  
  Char_t   tName[20];
  TPad *tPad;

  TIter tNextGraph(gList);
  TGraph *aGraph;

  for(Int_t i = 1; i<=600; i++) {
    Int_t pk=1;
    while (aGraph = (TGraph*)tNextGraph() ) {
      sprintf(tName,"c_%d",pk++); 
      tPad = (TPad*)c->GetPrimitive(tName);
      cout << i << " " << tName << endl;
      Float_t value =  gRandom->Rndm();
      for(Int_t k = 1; k<=10; k++) {
	aGraph->SetPoint(k-1, k*value, k*value*value);
      }
      tPad->Modified();             // needed for notifying that graph and pad were changed
      tPad->Update();               // needed for displaying the current graph
    }
    tNextGraph.Reset();
  }
}



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:51 MET