# Python macro and histogram with variable bin width

**URL:** <https://root-forum.cern.ch/t/python-macro-and-histogram-with-variable-bin-width/8417>\
**Category:** ROOT\
**Created:** [June 3, 2009, 10:13am UTC](https://root-forum.cern.ch/t/python-macro-and-histogram-with-variable-bin-width/8417 "2009-06-03T10:13:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abuechle](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@abuechle](https://root-forum.cern.ch/u/abuechle)\
**Post date:** [June 3, 2009, 10:13am UTC](https://root-forum.cern.ch/t/python-macro-and-histogram-with-variable-bin-width/8417/1 "2009-06-03T10:13:22Z")

</div>

Hi  
I tried to make a histogram with variable bin width in python, but was  
not successful.

Somehow this constructor seems not to be recognized…

Here is the code:

* * *

from ROOT import \*

binLowE = [2,4,9,15,20,22]

uniformTau = TH1D(“uniformTau”,"",5,binLowE)

uniformTau.FillN(5,10)

uniformTau.Draw()

* * *

TypeError: none of the 6 overloaded methods succeeded.

Please help.  
Cheers Angi

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [June 3, 2009, 6:04pm UTC](https://root-forum.cern.ch/t/python-macro-and-histogram-with-variable-bin-width/8417/2 "2009-06-03T18:04:19Z")

</div>

Angi,

the TH1::FillN() isn’t going to work with just two arguments, but to show how to pass a list through a double\* pointer:[code]from ROOT import \*  
from array import array

binLowE = [2,4,9,15,20,22]  
uniformTau = TH1D(“uniformTau”,"",5,array(‘d’,binLowE))  
#uniformTau.FillN(5,10)  
uniformTau.Draw()[/code]  
I.e. just use an array from module array. The buffer interface does the rest.

HTH,  
Wim
