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,

Trying putting this before any canvases are created:


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:



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

Thanks a lot,
All the solutions work!