# Binning of a histogram, read from a root file

**URL:** <https://root-forum.cern.ch/t/binning-of-a-histogram-read-from-a-root-file/50360>\
**Category:** Newbie\
**Created:** [June 10, 2022, 6:04pm UTC](https://root-forum.cern.ch/t/binning-of-a-histogram-read-from-a-root-file/50360 "2022-06-10T18:04:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjana](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@pjana](https://root-forum.cern.ch/u/pjana)\
**Post date:** [June 10, 2022, 6:05pm UTC](https://root-forum.cern.ch/t/binning-of-a-histogram-read-from-a-root-file/50360/1 "2022-06-10T18:05:00Z")

</div>

Hello,  
I have one root file, variables are saved as histograms. I plot one histogram from that root file. But I could not modify the bin size.  
Can anyone please help me?  
Thanks!!  
[aco.root](https://root-forum.cern.ch/uploads/short-url/axThYE8hSgeywu0sTGEEWOV1BxN.root) (7.0 KB)

* * *

> TCanvas\* c = new TCanvas();  
> TFile\* f = new TFile(“aco.root”);  
> TH1D\* h1 =(TH1D\* )f-\>Get(“dilepton\_acoplanarity\_all\_Data”);  
> h1-\>GetYaxis()-\>SetTitle(“Entries”);  
> c-\>SetLogy();  
> h1-\>Draw(“E1”);  
> h1-\>GetXaxis()-\>SetLimits(0,1);

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 10, 2022, 6:25pm UTC](https://root-forum.cern.ch/t/binning-of-a-histogram-read-from-a-root-file/50360/2 "2022-06-10T18:25:27Z")

</div>

Bin sizes are defined when the histogram is created.  
Afterward, you can only “merge” groups of bins, e.g.: [`h1->Rebin(10);`](https://root.cern/doc/master/classTH1.html#aff6520fdae026334bf34fa1800946790)

---

<div class="post-metadata">

**Author:** ![pjana](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@pjana](https://root-forum.cern.ch/u/pjana)\
**Post date:** [June 10, 2022, 6:46pm UTC](https://root-forum.cern.ch/t/binning-of-a-histogram-read-from-a-root-file/50360/3 "2022-06-10T18:46:34Z")

</div>

Thanks @Wile_E_Coyote ! I got it now.Thanks!
