# Binning in root file

**URL:** <https://root-forum.cern.ch/t/binning-in-root-file/48667>\
**Category:** Newbie\
**Tags:** root\
**Created:** [February 5, 2022, 11:07am UTC](https://root-forum.cern.ch/t/binning-in-root-file/48667 "2022-02-05T11:07:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/junkai/32/27450_2.png) [@JunKai](https://root-forum.cern.ch/u/JunKai)\
**Post date:** [February 5, 2022, 11:07am UTC](https://root-forum.cern.ch/t/binning-in-root-file/48667/1 "2022-02-05T11:07:45Z")

</div>

Hi everyone,  
I am curious that when viewing the histogram of a single branch in a TTree (I opened up a root file and clicked on the branch to view the histogram), why does in some of the case, the rebin option is less flexible than the other (as in figure b). I dont think that this is limited by entries number, because the root file in figures (a) and (b) have 1M and 5M entries respectively.  
Is is something to do with the saving process? If so, how do I take care of this when saving root files ?

Thanks in advance.

![image](https://root-forum.cern.ch/uploads/default/original/3X/a/b/ab31e44d699a859ace45fdc089f8c7738942ec4b.png)

\_ROOT Version: 6.24 (via cvmfs)  
_Platform:_ Ubuntu20.0LTS on WSL 2  
_Compiler:_ gcc9

* * *

---

<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:** [February 7, 2022, 7:47am UTC](https://root-forum.cern.ch/t/binning-in-root-file/48667/2 "2022-02-07T07:47:50Z")

</div>

Seems to me the left scale from -5 tp 5 is wrong. It should be a scale changing the number of bins. I see the same when I access and histogram produced by TTree::Draw. When I access an other histogram it is ok:

```auto
auto h = new*TH1F("h","h",500,0,1)
h->Draw()
h->Fill(0.5)
h->Draw()

```

 ![Screenshot 2022-02-07 at 08.43.41](https://root-forum.cern.ch/uploads/default/original/3X/4/2/42e60acc6aa699b771aedf8088ebb98f0373bdd7.png)

Note that it seems only the slider scale is wrong. When you move it changes the number of bins correctly. Same when you enter directly the number of bins in the text box.

---

<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:** [February 7, 2022, 8:56am UTC](https://root-forum.cern.ch/t/binning-in-root-file/48667/3 "2022-02-07T08:56:50Z")

</div>

Actually looking at the code, I see there is two different cases depending if the histogram comes from a tree or not. In the “tree case” the code is here:

> <https://github.com/root-project/root/blob/61e89ed8235f418e3721e576396759ed80ab75b8/gui/ged/src/TH1Editor.cxx#L403>

I have no idea it was done that way …

---

<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:** [February 7, 2022, 9:24am UTC](https://root-forum.cern.ch/t/binning-in-root-file/48667/4 "2022-02-07T09:24:31Z")

</div>

The doc is here:

> <https://github.com/root-project/root/blob/61e89ed8235f418e3721e576396759ed80ab75b8/gui/ged/src/TH1Editor.cxx#L65-L96>
