# Binning of histograms and accessing spectrum manipulation functions

**URL:** <https://root-forum.cern.ch/t/binning-of-histograms-and-accessing-spectrum-manipulation-functions/62552>\
**Category:** Newbie\
**Created:** [December 29, 2024, 7:10am UTC](https://root-forum.cern.ch/t/binning-of-histograms-and-accessing-spectrum-manipulation-functions/62552 "2024-12-29T07:10:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [December 29, 2024, 9:56am UTC](https://root-forum.cern.ch/t/binning-of-histograms-and-accessing-spectrum-manipulation-functions/62552/4 "2024-12-29T09:56:21Z")

</div>

> [@Numpy arrays in variable binned histogram with pyroot](https://root-forum.cern.ch/t/numpy-arrays-in-variable-binned-histogram-with-pyroot/24070):
>
> Hello, I am using root-6.08.02 to make a variable binned histogram with PyROOT. I find that this works: from array import array m = [400,450,500,550,600,650,700,750,800,850,900,950,1000,1150,1500] h = ROOT.TH1D("h",";m [GeV];Events/ 50 GeV;;",len(m)-1,array('d',m)) but this doesn’t import numpy as np m = [400,450,500,550,600,650,700,750,800,850,900,950,1000,1150,1500] h = ROOT.TH1D("h",";m [GeV];Events/ 50 GeV;;",len(m)-1,np.asarray(m)) I error I get is Error in \< TGaxis::PaintAxis \>: len…

> [@Problem constructing TH2F](https://root-forum.cern.ch/t/problem-constructing-th2f/8895/6):
>
> (Number of bins = array\_dimension) gives: root [0] Double\_t b\_f[9]={0.,0.1,0.16,0.2,0.25,0.3,0.35,0.4,0.6}; root [1] TH2F\*h=new TH2F("a","a",10,0,1,9,b\_f) Error in \<TAxis::TAxis::Set\>: bins must be in increasing order root [2] (Number of bins = array\_dimension-1) gives: root [0] Double\_t b\_f[9]={0.,0.1,0.16,0.2,0.25,0.3,0.35,0.4,0.6}; root [1] TH2F\*h=new TH2F("a","a",10,0,1,8,b\_f) root [2] That’s logic, the array defines the bins’ boundaries.

---

_[View the full topic](https://root-forum.cern.ch/t/binning-of-histograms-and-accessing-spectrum-manipulation-functions/62552)._
