Plotting ASCII files in ROOT

后端 未结 3 1627
误落风尘
误落风尘 2020-12-22 12:11

I am trying to write a small macro that reads data from an ASCII file that has 4 columns. But I want to graph only the second the third columns as (x, y).

3条回答
  •  鱼传尺愫
    2020-12-22 12:44

    The constructor of TGraph can directly take a CSV file, see the documentation.

    TGraph g("data.csv", "%*lg %lg %lg %*lg", ",");
    

    The first argument is the filename, and the second argument a format string. Skipped columns are denoted with a *; to skip the last column you could actually just omit it from the format string,

    %*lg %lg %lg
    

    The third argument is the column separator which might be , for your flavor of CSV.

提交回复
热议问题