Dear experts, I have observed a very interesting effect of the use of the batch mode in ROOT to produce plot… the PNG (and PDF) that are obtained from the TCanvas::SaveAs command are different, even in the dimensions.
I am using the following, although it should not be that relevant
ROOT Version: 6.34.06 (but probably in all of them)
Platform: Alma 9 (but probably in most of them)
Compiler: N/A
Ok, using the following example code:
void example (void) {
auto *c = new TCanvas("test","Test",0,0,600,600);
c->Draw();
c->SaveAs("test.pdf"); // 546 x 567 pts, 544 x 567 pts in batch
c->SaveAs("test.png"); // 598 x 576, 596 x 572 in batch
}
I obtain (as mentioned in the commends above) different dimensions for the PNG and the PDF files if I run it normally or with the batch mode, i.e.:
$ root example.C
$ root -b example.C
Something that is interesting is that none of them actually matches the dimensions I indicated to the TCanvas (600x600). Although not that problematic, it is also a problem.
Byt the way, running the python-equivalent code in pyroot is the same as in C++… meaning, the problem is there.
I admit that it may be that any of my environment or initialization parameters may be impacfting this, but it may help me to know which one. I do not like that the plots are different to the dimensions I indicate (600x600), but the worse is that the fact that running ROOT in batch(*) mode changes the actual outcome… that makes reproducibility hard to achive.
So any help and feedback is welcome! Thanks a lot in advance,
Oscar.
(*) The “-b” is not the cause, as I can just unset the DISPLAY variable and even the first command will produce the “batch mode” result. That is how I discovered the issue as running some of my code remotely (gitlab CI) was giving different figures as locally.