I have saved in the file with .py extension and from terminal I have launched the macro, but I donât see the canvas⌠and I obtain the same result with the example in the tutorial folder of ROOT.
Why?? How can I do?
And there is a method for import all lib ROOT, because if i do :
import ROOT donât work, I have to do for example:
from ROOT import gROOT, TCanvas, TF1
I have the same problem here, I have successfully installed ROOT + PyROOT (ver. 6.06/08 +python34 on OSX using macports). Everything works, the only problem is that the plots are shown on the screen, but immediately disappear. I have tried the above suggestions which did not help. Also tried:
import os
os.popen(âpython graph.pyâ)
because execfile seems to be deprecated. also didnât help. Any ideas?
in all cases, you have to make sure that the python process that is displaying the canvas is alive for the duration that you want to have the canvas displayed.
E.g. in this:import os
os.popen(âpython graph.pyâ)you create a subprocess that exists after the end of the script.
As for execfile, you can compile the script and exec it, but what is wrong with simply importing it?
inside a python session. Plot is shown and stays. But this does not seem to be the most convenient way. I was expecting a sort of way to tell PyROOT to wait after plotting, like plots in matplotlib, so that one can just run the script as a stand alone program by:
After some digging, it seems there might be some hints in the call to ROOT.gROOT.IsBatch(). But I am absolutely no expert, so I am not sure.
Finally I found a trick. I added the following line at the end of the tutorial file graph.py:
Then it worked as expected. The reason is that the outer python process is kept alive.