TGraph2D for different sizes of X and Y?

Hello,

I’m trying to plot a 2D graph with TGraph2D where I have X and Y with different sizes.

Searching on TGraph2D documentation, I see that X and Y must be the same size. Is that correct? If that’s true, how can I plot a 2D graph with X and Y with different sizes?

I always get the same error:

Error: Can’t call TGraph2D::TGraph2D(num_days,Days,Latitude_Angle,Radiance_31) in current scope Solar_Radiance.C:863:
Possible candidates are…
(in TGraph2D)
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(void);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(Int_t n);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(Int_t n,Int_t* x,Int_t* y,Int_t* z);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(Int_t n,Float_t* x,Float_t* y,Float_t* z);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(Int_t n,Double_t* x,Double_t* y,Double_t* z);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(TH2* h2);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(const char* name,const char* title,Int_t n,Double_t* x,Double_t* y,Double_t* z);
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(const char* filename,const char* format="%lg %lg %lg",Option_t* option="");
/usr/lib/x86_64-linux-gnu/root5.34/libHist.so -1:-1 0 public: TGraph2D TGraph2D::TGraph2D(const TGraph2D&);
Error: Illegal Assignment to an undeclared symbol Gra2D Solar_Radiance.C:863:
*** Interpreter error recovered ***

Thanks a lot!

Hi,

The Graph2D contains the list of ‘coordinate’ so indeed it ought to have the same number of X and Y.

You may want to look into TH2D instead.

Cheers,
Philippe.

Thanks a lot! :slight_smile: