This bug is driving me crazy. I just don’t know what to do.
Assume we have a numpy array and want to make a TGraph.
data = np.array([[1.1, 1.0, 1.2], [ 1.3, 1.2, 1.5], [ 1.7, 1.2, 1.1], [ 1.2, 1.9, 1.5]])
x, y = data[0], data[1]
ROOT.TGraph(len(x), x, y) # works
But if we try to plot columns, not rows
x, y = data[:,0], data[:1]
ROOT.TGraph(len(x), x, y) # error
This path guides to the very same error
data = data.T
x, y = data[0], data[1]
ROOT.TGraph(len(x), x, y) # error
The error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: none of the 11 overloaded methods succeeded. Full details:
TGraph::TGraph() =>
takes at most 0 arguments (3 given)
TGraph::TGraph(Int_t n) =>
takes at most 1 arguments (3 given)
TGraph::TGraph(const TGraph& gr) =>
takes at most 1 arguments (3 given)
TGraph::TGraph(const TVectorF& vx, const TVectorF& vy) =>
takes at most 2 arguments (3 given)
TGraph::TGraph(const TVectorD& vx, const TVectorD& vy) =>
takes at most 2 arguments (3 given)
TGraph::TGraph(const TH1* h) =>
takes at most 1 arguments (3 given)
TGraph::TGraph(const TF1* f, Option_t* option = "") =>
takes at most 2 arguments (3 given)
TGraph::TGraph(const char* filename, const char* format = "%lg %lg", Option_t* option = "") =>
could not convert argument 1 (expected string or Unicode object, int found)
TGraph::TGraph(Int_t n, const Int_t* x, const Int_t* y) =>
could not convert argument 2
TGraph::TGraph(Int_t n, const Float_t* x, const Float_t* y) =>
could not convert argument 2
TGraph::TGraph(Int_t n, const Double_t* x, const Double_t* y) =>
could not convert argument 2
Why does that happen? Also how to plot columns against each other (not rows) in such a case?
P.S.
I need to use TGraph (more precisely TGraphAsymmErrors), to fit the data. Matplotlib is not a solution.
P.P.S
Also I found out that TGraph crashes with python list.
MacOS 10.12.1, Python 2.7.10, ROOT 5.34/36 (installed via Homebrew)