GetBinCenter(): passing a pointer in python

I am trying to get a list of bin centers of a TH1D in python, but getting errors:

va = np.array([0] * n);
ce = h1.GetCenter(va)

gives: TypeError: could not convert argument 1 (could not convert argument to buffer or nullptr)

Answers I found said passing a numpy array should work, but I am having trouble :confused:


I am actually trying to convert ROOT histograms to matplotlib (to work with pyMC3 output), so pointers to a good source that already does that is also appreciated

va = np.array([0.] * h1.GetNbinsX(), np.double) ; h1.GetCenter(va)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.