Why does TCanvas not draw during the execution of a macro in the root shell?

3.5k views Asked by At

Suppose I have a macro that contains two TGraphs: T1 and T2 and I have a canvas "C" divided into two parts:

TCanvas *C = new TCanvas("","",0,0,400,400);
C->Divide(2,1);

when this part gets executed the blanc canvas appears on my screen but it's grayed out.. inactive! But that's okay, then it proceeds..

The program has two distinct parts, in the first part it completes calculations enters the first half of the canvas and draws the first TGraph:

C->cd(1);
T1->Draw("AP");

at this point I expect to already see the graph on the first half of the canvas but unfortunately nothing appears, the canvas remains inactive! The program proceeds to the next part:

C->cd(2);
T2->Draw("AP");

same story nothing appears on the canvas yet, but then the execution finishes and I am back to the root shell as in like this:

root[#]

and now I can see the two graphs! What I want is that the parts that have been executed like T1->Draw("AP") should already appear on the cd(1) and then later the graph on cd(2) should appear. Is there a way to achieve that?

1

There are 1 answers

0
quanta On

OK, I found a solution in the CERN-ROOT's thread:

https://root.cern.ch/phpBB3/viewtopic.php?t=13082

where the user "couet" suggested to use

C->Modified(); C->Update();

after each "C->Draw();"

I applied this to my problem and it worked.