I want update a TGraph2D every time I add point to simulate a trajectory.
The following code update the canvas and axis but not the point.
If I remove Update() and ProcessEvents(), the macro draw correctly all points at the same time. I tried with and without ProcessEvents() but nothing works.
Thanks.
Macro.C
{
auto c = new TCanvas ("c","", 1000, 1000 ,1000 ,1000);
auto gr = new TGraph2D();
gr->SetMarkerStyle(20);
gr->Draw("P");
for(int i=0; i<30; i++){
gr->SetPoint(gr->GetN(), i+1, i-1, 1);
gPad->Modified();
gPad->Update();
gSystem->ProcessEvents();
}
gr->Print();
}
Yes, I can reproduce the problem.
Reason is that painter is not updated when TGraph2D get new points.
There is simple workaround for now - just add gr->SetMargin(0); after gr->SetPoint(...).
This force recreation of histogram and all objects painters.
And I will try to provide fix that TGraph2D painter will work properly.