I’ve recently upgraded from ROOT 5.34.17 to 5.34.24 (running Fedora 20 Linux, clang++ 3.4.2) and encountered an issue when running codes I have developed that output a PNG file from a TCanvas running in batch mode. Using the following CINT code snippet:
C = new TCanvas("","",0,0,1000,500);
H = new TH1F("H","H",100,-5,5);
On 5.34.17, stdout gives
Info in <TCanvas::Print>: file /tmp/tmp.png has been created
and a PNG file is correctly produced.
On 5.34.24, there is no stdout output and no file is created. Curiously, changing the TCanvas::Print() command to
will output an PS formatted file!
I couldn’t find any indication in the version changes that this was intentional, and there’s very little in the documentation on TCanvas in batch mode (i.e. no window).
Does anyone have any insight here? Perhaps I just missed something! Thanks very much!
TCanvas *C = new TCanvas(“C”,"",0,0,1000,500); // you need to set the name of the canvas
The correct C++ code is:
TCanvas *C = new TCanvas("C","",0,0,1000,500);
TH1F *H = new TH1F("H","H",100,-5,5);
One additional note.
If you want to run in “batch mode” … either run “root -b” (try “root -?” in order to see available options) … or … add “gROOT->SetBatch(kTRUE);” in your macro (before you create any canvas).
Hi WIle E. and Oliver,
Thanks both for the quick respones. For my particular application - I’m running IPython Notebooks and have developed a derived TCanvas class that enables ROOT graphics to be embedded within the notebooks - the right solution was to call the
gROOT.SetBatch(True) method before calling the constructor of my derived TCanvas object since starting ROOT with the ‘root -b’ call is not an option in this case. I have given the TCanvas a name per Oliver’s suggestion just in case … I should realize by now that ROOT objects should ALWAYS be named to prevent bad things from occurring!