Plotting one TGraph after another


I have been trying to figure out a problem for a while now, but I hope someone here knows what’s going on.

I have a macro that consists of an infinite loop, in which I ask the user for some info, extract data from a file, create a canvas, then plot the data in a TGraph or a TH1F, depending on the user selection. Then it loops back and asks if another plot is desired, or if the user wants to quit.

Here is my problem. Everything works fine, except the ROOT window that opens with the canvas is not accessible to user interactions until the user chooses to quit. What I mean by this is that the plot shows up and the program continues to loop where I can keep plotting different graphs, but the menu bar is inaccessible, the plot range cannot be changed, etc… it is as if the program is “frozen.” Then, when the user chooses to quit, the program exits from its loop and the menu bar and everything can then be accessed, only on the last graph. It gets annoying having to quit the program to analyze the data, and then start it again to get another graph.

Does anyone know what the problem could be? Thanks in advance for any help.


Hi Corey,

You need to use in your code: gSystem->ProcessEvents(); that will allow your macro loop to be interrupted by some GUI events according to the interval in which this method is called).

Best regards, Ilka

Thanks for the help… worked like a charm.

For others who have the same problem, I used:

and this loops until the user presses CTRL-C on the canvas.