我有一个两列文件,有1000000个条目,即1000000行,但是我不想绘制所有数据,我只想绘制每100行的点数?如何在gnuplot中这样做?另外,是否可以在gnuplot中指定一些特定的行?
mgi*_*son 26
这里至少有两个选项.首先,查看文档help datafile every
plot 'datafile' every 100 using 1:2
Run Code Online (Sandbox Code Playgroud)
另一个选择是使用伪列0(help datafile using pseudo)和三元运算符(help ternary)以及gnuplot静默忽略未定义数字以过滤行的知识:
plot 'datafile' u ( ((int($0)%100)==0)? $1 : 1/0 ):2
Run Code Online (Sandbox Code Playgroud)
如果使用宏,可以使这更容易理解:
set macro
line_number='int($0)'
plot 'datafile' u ( ( ( @line_number % 100 ) == 0 ) ? $1 : 1/0 ) : 2
Run Code Online (Sandbox Code Playgroud)
请注意,我只包括第二个,因为你可以(原则上)使用它从数据文件中选择非常奇怪的行号(例如1,100,1000,10000),你不能使用每个 - 例如
plot 'datafile' u ( ((@line_number == 1 || @line_number == 100 || @line_number == 1000 ) $1:1/0)):2
Run Code Online (Sandbox Code Playgroud)
另请参阅此问题的答案