# Handling zero bin contents

**URL:** <https://root-forum.cern.ch/t/handling-zero-bin-contents/63934>\
**Category:** Newbie\
**Created:** [July 25, 2025, 3:40pm UTC](https://root-forum.cern.ch/t/handling-zero-bin-contents/63934 "2025-07-25T15:40:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phylmath](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/phylmath/32/38400_2.png) [@phylmath](https://root-forum.cern.ch/u/phylmath)\
**Post date:** [July 25, 2025, 3:40pm UTC](https://root-forum.cern.ch/t/handling-zero-bin-contents/63934/1 "2025-07-25T15:40:43Z")

</div>

_ROOT Version:_ 6.32.04  
_Platform:_ WSL2 Ubuntu

Hello! Is it possible to draw a histogram but skip the bins that have zero contents? The reason I ask is that I am plotting several histograms on the same canvas spaced by a factor of 1E10 (a spacing of 10 on a log scale). However, because the histograms on top have a few zero bins it drops lines to the bottom and messes up the rest of the canvas.

Any solutions? Thank you in advance.

Cheers, Philip.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/6/f645aa1e2f8487a0c6c8a504c073b98dde08b4e1.png)

---

<div class="post-metadata">

**Author:** ![jocl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jocl/32/35197_2.png) [@jocl](https://root-forum.cern.ch/u/jocl)\
**Post date:** [July 26, 2025, 1:01am UTC](https://root-forum.cern.ch/t/handling-zero-bin-contents/63934/2 "2025-07-26T01:01:37Z")

</div>

Do you absolutely need to draw lines? If not, I would try `hist->Draw("P");`

This will draw with points instead of lines (you should also probably set your marker style, color, and size), so it won’t show the 0 bins.

---

<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:** [July 28, 2025, 6:24am UTC](https://root-forum.cern.ch/t/handling-zero-bin-contents/63934/3 "2025-07-28T06:24:57Z")

</div>

If you really need lines drawing you can also [make graphs from your histograms](https://root.cern.ch/doc/master/classTGraph.html#af952097ee465684b9b2c28ada0e57814) and [then loop over the graph points](https://root.cern.ch/doc/master/classTGraph.html#a0fc3ceffa9df77da0cc5747be8ebcacf) and [remove the points with y = 0](https://root.cern.ch/doc/master/classTGraph.html#a8f605efa77deeeeaf6e7ceffea07dbc5).
