# How to define histogram with variable bin width in python

**URL:** <https://root-forum.cern.ch/t/how-to-define-histogram-with-variable-bin-width-in-python/27110>\
**Category:** ROOT\
**Created:** [November 30, 2017, 6:02am UTC](https://root-forum.cern.ch/t/how-to-define-histogram-with-variable-bin-width-in-python/27110 "2017-11-30T06:02:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 30, 2017, 7:51am UTC](https://root-forum.cern.ch/t/how-to-define-histogram-with-variable-bin-width-in-python/27110/2 "2017-11-30T07:51:11Z")

</div>

See for example:

> [@Python macro and histogram with variable bin width](https://root-forum.cern.ch/t/python-macro-and-histogram-with-variable-bin-width/8417/2):
>
> 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

(searching on the forum is sometimes useful…) 😉

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-define-histogram-with-variable-bin-width-in-python/27110)._
