[ROOT] graph problem

From: Galina Asova (assova@ifh.de)
Date: Fri Feb 13 2004 - 10:57:21 MET


Dear ROOT users,

I have a problem with graphs when I try to plot a point immediately 
after calculating its value - updating the graph during runtime. With 
TH1F this works - the plot is filled but with TGraph I don't see any 
updating. Here is a piece of code - I tried to compare in which way this 
is possible:

//TGraph
TCanvas *can = new TCanvas("Graph", "Graph!");
Float_t *a = new Float_t[100];
Float_t *b = new Float_t[100];
TGraph *gr = new TGraph(100, a, b);
gr->Draw("AP*");
	
for (int i = 0; i < 100; i++){
	a[i] = i;
	b[i] = 5 * sin(i);
	can->Modified();
	can->Update();
	printf ("calculated\n");
	gSystem->ProcessEvents();
}

//TH1F
TCanvas *c1 = new TCanvas("c1","Time on axis");
Float_t bins = 1;
TH1F *ht = new TH1F("Histo","Histo",100,0,10*bins);
ht->GetXaxis()->SetRange(1, 1000);
ht->GetYaxis()->SetNdivisions(1000);
ht->SetMarkerStyle(20);
ht->Draw("AP*");
for (Int_t i=0;i<100;i++) {
       Float_t val  =  sin(i);
       ht->SetBinContent(i,val);
       c1->Modified();
       c1->Update();
       gSystem->ProcessEvents();
}


Do I miss anything? Do you know a way to achieve this?
I'm using Linux Suse 8.2 with ROOT 3.10
Thanks



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET