# Dimension changes in SaveAs Canvas for batch mode

**URL:** <https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385>\
**Category:** Newbie\
**Tags:** graphics\
**Created:** [April 14, 2025, 12:24pm UTC](https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385 "2025-04-14T12:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oglez](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/df788c/32.png) [@oglez](https://root-forum.cern.ch/u/oglez)\
**Post date:** [April 14, 2025, 12:24pm UTC](https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385/1 "2025-04-14T12:24:59Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [April 14, 2025, 1:34pm UTC](https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385/2 "2025-04-14T13:34:48Z")

</div>

Check this thread

> [@TCanvas size](https://root-forum.cern.ch/t/tcanvas-size/55519/2):
>
> TCanvas\* c0 = new TCanvas("c0", "c0", 30, 30, 600, 600); this defines the window size, not the canvas size. To control the canvas size, you need to add c0-\>SetCanvasSize(yourwidth,yourheight); see the [Documentation](https://root.cern/doc/master/classTCanvas.html).

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [April 14, 2025, 4:54pm UTC](https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385/3 "2025-04-14T16:54:16Z")

</div>

Thanks for the report, yep, known issue: [TCanvas size is inconsistent in batch vs non-batch mode · Issue #11004 · root-project/root · GitHub](https://github.com/root-project/root/issues/11004)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 15, 2025, 11:35am UTC](https://root-forum.cern.ch/t/dimension-changes-in-saveas-canvas-for-batch-mode/63385/4 "2025-04-15T11:35:18Z")

</div>

See the paragraphe about **SetWindowSize** here: [ROOT: TCanvas Class Reference](https://root.cern/doc/master/classTCanvas.html)
