在ROOT中绘制ASCII文件 [英] Plotting ASCII files in ROOT

查看:210
本文介绍了在ROOT中绘制ASCII文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个小宏,它从具有4列的ASCII文件读取数据。但我想只将第二列的第三列作为(x,y)。

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).

推荐答案

TGraph 的构造函数可以直接获取CSV文件, 文档

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

第三个参数是列分隔符,可能是为您的CSV风味。

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

这篇关于在ROOT中绘制ASCII文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆