Re: [ROOT] graph problem

From: Ingo Strauch (strauch@mail.desy.de)
Date: Fri Feb 13 2004 - 14:23:56 MET


Galina Asova wrote:
> 
> 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();
> }

You never change the graph in your example.

I think you have to add a line like

  gr->SetPoint(i,a[i],b[i]);

before the can->Modified();

Cheers,
Ingo

-- 
"What're quantum mechanics?"
"I don't know. People who repair quantums I suppose."
                                     --Rincewind, Terry Pratchett "Eric"



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