Hi!
I would like to draw a TGraph from a .txt file with 2 columns. What I already have is two arrays (let’s say x and y) in c++ code, but I’m stuck on plotting them. So I read the first column as one array and the second as the other, now I have to insert the right arrays instead of x and y, but I seem to miss something, because I always get an error. Any help on how to get the plot work would be appreciated
Cheers
{
Int_t N = 100;
string data_array[N][2];
ifstream in_file("test.txt", ios::binary);
if(!in_file.is_open()){
cout << "File not opened..." << endl;
}
for(int i=0; !in_file.eof(); i++){
in_file >> data_array[i][0];
in_file >> data_array[i][1];
}
for(int i=0; i<N; i++){
cout << data_array[i][0] << " " << data_array[i][1] << '\n';
}
//TGraph *plot = new TGraph(N,x,y);
//plot->Draw();
}