No graphical interface (as root -b)

Dear expert,

I’m using some pyroot to create some plots. The code uses the Draw function, and it opens each time the histogram, slowing down the process.
There is an easy way to do not use the graphical interface and simply save the plot (without changing the code), as for instance it is possible with the “root -b” option?
I tried to log in with ssh without -X and -Y, but it opens each plot each time.

Thanks a lot,
Luca

Trying putting this before any canvases are created:

ROOT.gROOT.SetBatch(ROOT.kTRUE)

Also if you are using TTree::Draw, the “goff” option is quite useful for creating histograms in memory without drawing them graphically.

If you end up switching between Batch and Non-Batch mode in the same script, you might want to read this:
[url]SetBatch(ROOT.kFALSE)?

Jean-François

Hi,

also, you can hand the ‘-b’ to python, just make sure to either use a script file name or ‘-’. As in:$ python script.py -bor:$ python - -bThen ‘import ROOT’ as normal.
Cheers,
Wim

Thanks a lot,
All the solutions work!

Best,
Luca