Hi everyone, I have a script that needs to fit some histograms and access axes, so I need to draw them. I don’t actually care for the graphics until the end, and in the process some dozens of canvases are created. This steals the focus every ~10 seconds and is quite vexing.

I saw on some forums that I could set gROOT.SetBatch() to enable batch mode, but am I able to later “UnsetBatch”, by passing a false value? It doesn’t seem to work, even after ROOT.gROOT.SetBatch(ROOT.kFALSE), new canvases and drawn things don’t show up graphically.

Is there a histogram-drawing equivalent of TTree::Draw’s “goff” option? That would work too, but I couldn’t find anything similar in the docs for THistPainter.



from the TCanvas documentation:[quote]void SetBatch(Bool_t batch = kTRUE)
Toggle batch mode. However, if the canvas is created without a window
then batch mode always stays set.[/quote](Looking at the code, the reason is that the underlying TCanvasImp is a different class (or at least, originates from a different factory).)

Does is make sense to draw on a TPad until all is done, and only then create a TCanvas to draw the TPad on?


I don’t think understand your answer. If I do ROOT.gROOT.SetBatch(ROOT.kTRUE) before any of the commands involving canvases and histogram drawing, indeed none of the windows are created and nothing steals focus. Afterwards, when I do ROOT.gROOT.SetBatch(ROOT.kFALSE), later canvases and draw commands are still not shown. It’s like the batch mode “sticks” and I can’t return it to non-batch mode.

The documentation you quote says that SetBatch “toggles” batch mode, so I also tried doing ROOT.gROOT.SetBatch(ROOT.kTRUE) a second time to disable batch mode, but the result is the same.

You suggest that I draw on a TPad until everything is done and only create a TCanvas at the end. How do I do that? I am using histogram->Draw().


yes, batch mode “sticks”: any TCanvas’s created when the mode (either globally or on the TCanvas) is “batch”, will never be able to display: they’ll have a different internal implementation class. Think of it this way, if you do gROOT.SetBatch(), then every call “c = TCanvas()” is in reality a “c = TBatchCanvas()”.

Supposedly TCanvas’s created after batch has been toggled back to “off” should display, but I just tried (on root.exe as well) and it doesn’t actually work.

For TPad, I was expecting that it would be possible to add primitives directly, but it does not work either.

This is outside of my expertise … only other think I can think of (other than trying the ROOT support forum) is to save what you want to draw on each TCanvas in separate lists and call Draw on those entries in turn once you’re ready to display them.