# Saving histograms in a list using PyROOT

**URL:** <https://root-forum.cern.ch/t/saving-histograms-in-a-list-using-pyroot/60478>\
**Category:** ROOT\
**Tags:** python\
**Created:** [August 13, 2024, 1:08pm UTC](https://root-forum.cern.ch/t/saving-histograms-in-a-list-using-pyroot/60478 "2024-08-13T13:08:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 13, 2024, 1:26pm UTC](https://root-forum.cern.ch/t/saving-histograms-in-a-list-using-pyroot/60478/2 "2024-08-13T13:26:40Z")

</div>

Instead of adding them to a list, add them to THStack (in that same loop), then just draw the THStack. See this recent post with a similar case:

> [@Overlaying histograms with pyROOT](https://root-forum.cern.ch/t/overlaying-histograms-with-pyroot/60454):
>
> I am needing to overlay several histograms in several different ROOT files. I am trying to accomplish this in pyROOT. I am first trying just to import a histogram from an existing ROOT file and saving it as a png image. I can’t even seem to get this far. The png saves as just a blank image according to the pixel dimensions I specified. For reference, here is my Python code: import ROOT def overlay\_test(): file1 = ROOT.TFile.Open("Baylor/root/local\_runs/1050\_2023\_HB3\_ped.root") can…

---

_[View the full topic](https://root-forum.cern.ch/t/saving-histograms-in-a-list-using-pyroot/60478)._
