TGraphErrors constructor and TGraph::SaveAs inconsistent?

Hi,

I just found out about the possibiliy to instantiate a TGraphErrors from a txt or csv file that I like very much!

However, I think I found inconsitency (I believe) in loading a TGraphErrors from csv and saving to csv, that actually makes it impossible to instantiate a TGraphErrors from a file just saved with TGraph::SaveAs(file), since the load order is (see documentation)

format = "%lg %lg %lg %lg" read only 4 first columns into X,Y,EX,EY.

while the save order is (from TGraph.cxx, TGraph::SaveAs, line 2137 in master branch)

out << fX[i] << del << (ex?ex[i]:0) << del << fY[i] << del << (ey?ey[i]:0) << std::endl;

i.e. X,EX,Y,EY. I think it would be beneficial that TGraphErrors could read its own output. Or did I miss some option to set the read/save order manually?

Best regards and thanks,
Klaus


ROOT Version: 6.36
Platform: Debian12
Compiler: Not Provided


Thanks for reaching out! I’m sure @couet will take a look once he’s back

Hi Klaus,

Looks like reading and writing graphs with errors are inconsistent.
I propose not to change current implementation,
but add store option like “asroot” to change order of values.

Regards,
Sergey

And I add PR with proposed changes: Extend TGraph::SaveAs functionality by linev · Pull Request #20368 · root-project/root · GitHub

Please check if it fir to your needs.

1 Like

Thanks for taking care!