# Redraw TH1 and omit the empty histos

**URL:** <https://root-forum.cern.ch/t/redraw-th1-and-omit-the-empty-histos/15858>\
**Category:** ROOT\
**Created:** [March 29, 2013, 1:19am UTC](https://root-forum.cern.ch/t/redraw-th1-and-omit-the-empty-histos/15858 "2013-03-29T01:19:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jfcaron](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jfcaron](https://root-forum.cern.ch/u/jfcaron)\
**Post date:** [March 29, 2013, 4:01am UTC](https://root-forum.cern.ch/t/redraw-th1-and-omit-the-empty-histos/15858/4 "2013-03-29T04:01:59Z")

</div>

For a THStack you will need to loop over the contained histograms, or use the “last” histogram which contains the sum. See this discussion regarding the same issue in PyROOT:

> [@FindFirstBinAbove for THStack](https://root-forum.cern.ch/t/findfirstbinabove-for-thstack/15589/1):
>
> Hi, I quite enjoy making histograms with a fixed bin width where I set the maximum/minimum bins to very large values to avoid overflows. E.g. in PyROOT: binwidth = 0.1 minbin,maxbin = -1000,1000 nbins = (maxbin-minbin)/binwidth h = ROOT.TH1F("h","h",nbins,minbin,maxbin) Then to draw the histogram properly for looking at, I use: firstbin = h.FindFirstBinAbove(0) lastbin = h.FindLastBinAbove(0) h.GetXaxis().SetRange(firstbin,lastbin) I have now a THStack with multiple histograms in it, and it i…

Jean-François

---

_[View the full topic](https://root-forum.cern.ch/t/redraw-th1-and-omit-the-empty-histos/15858)._
