Appending a 1D histogram to a PDF file from a "for" loop

Hello all,

I’m trying to export histograms (with vertical lines overlayed) created in a “for” loop to a single PDF file with the goal to have all 100 histograms in the file. I have been reading similar posts whose problems are similar to mine but I haven’t been able to work it out. ROOT does export all 100 histograms to a PDF file, however, each file is subsequently overwritten by the next histogram resulting in the file containing only the last histogram. The code which is of concern is:


I feel like I’m close but any help would be appreciated. Thanks in advance!

ROOT Version: 6.24.06
Platform: Windows 11
Compiler: Jupyter Notebook

The example of the TPDF documentation shows how to do a multipage document. Note the added “(” in the first page to start the multipage, then close the last one with “)”.


Thanks, it works! Only thing I had to add is an “if/ elif” at the end of the “for” loop for the PDF to properly update

ROOT Help 3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.