TGraphErrors, 2D array allowed?

Hello rooters,

I have one question regarding the
TGraphErrors(Int_t n,const Float_t* x,const Float_t* y,const Float_t* ex=0,const Float_t* ey=0))
I stored my data in a two dimensional array and want to make a plot out of each column in different canvas. I tried like this:
TGraphErrors *gr = new TGraphErrors(n,x_bin[][1],px[][1],dpx[][1],dpx[][1]);

But it does not work. Is there any way to do this?

Thanks,
Wei

Hi Wei,

[quote=“lwsy711”]I have one question regarding the
TGraphErrors(Int_t n,const Float_t* x,const Float_t* y,const Float_t* ex=0,const Float_t* ey=0))
I stored my data in a two dimensional array and want to make a plot out of each column in different canvas. I tried like this:
TGraphErrors *gr = new TGraphErrors(n,x_bin[][1],px[][1],dpx[][1],dpx[][1]);
[/quote]

I don’t think this is a Root problem, but a C++ one. You might be able to get away with (if you switched your two columns)

TGraphErrors *gr = new TGraphErrors(n,x_bin[1],px[1],dpx[1],dpx[1]);

But what you have doesn’t make any C++ sense.

Cheers,
Charles

p.s. float array[10][5] means that array[3] for example is a a pointer to an array of floats of length 5.

[quote=“cplager”]Hi Wei,

[quote=“lwsy711”]I have one question regarding the
TGraphErrors(Int_t n,const Float_t* x,const Float_t* y,const Float_t* ex=0,const Float_t* ey=0))
I stored my data in a two dimensional array and want to make a plot out of each column in different canvas. I tried like this:
TGraphErrors *gr = new TGraphErrors(n,x_bin[][1],px[][1],dpx[][1],dpx[][1]);
[/quote]

I don’t think this is a Root problem, but a C++ one. You might be able to get away with (if you switched your two columns)

TGraphErrors *gr = new TGraphErrors(n,x_bin[1],px[1],dpx[1],dpx[1]);

But what you have doesn’t make any C++ sense.

Cheers,
Charles

p.s. float array[10][5] means that array[3] for example is a a pointer to an array of floats of length 5.[/quote]

Charles,
It works. Thanks for pointing out the stupid mistake I made.
Wei