如何在GNUplot中绘制特定行 [英] How to plot specific rows in GNUplot

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

问题描述

我有一个两列文件,其中有1000000个条目,即1000000行,但是我不想绘制所有数据,我只想每100行绘制点?如何在gnuplot中做到这一点?另外,是否可以指定一些特定的行在gnuplot中绘制?

I have a two-column file which has 1000000 entries, that is 1000000 rows, however I don't want to plot all the data, I just want to plot the points every 100 lines? How to do this in gnuplot? Also, is it possible to specify some particular rows to plot in gnuplot?

推荐答案

您在这里至少有两个选择.首先,查看help datafile every

You have at least two options here. First, check out the documentation for help datafile every

plot 'datafile' every 100 using 1:2 

另一种选择是将伪列0(help datafile using pseudo)与三元运算符(help ternary)结合使用,并且gnuplot会默默地忽略未定义的数字来过滤行:

Another option is to use the pseudo-column 0 (help datafile using pseudo) in conjunction with the ternary operator (help ternary) and the knowledge that gnuplot silently ignores undefined numbers to filter the lines:

plot 'datafile' u ( ((int($0)%100)==0)? $1 : 1/0 ):2

如果使用宏,可以使这一点更容易理解:

You can make this a little more easy to understand if you use a macro:

set macro
line_number='int($0)'
plot 'datafile' u ( ( ( @line_number % 100 ) == 0 ) ? $1 : 1/0 ) : 2

请注意,我只包含第二个,因为(原则上)您可以使用它从数据文件中选择非常奇怪的行号(例如1,100,1000,10000),而您不能使用每个-例如

Note that I only include the second because you could (in principle) use this to select very strange line numbers from the datafile (e.g. 1,100,1000,10000) which you can't do using every -- e.g.

plot 'datafile' u ( ((@line_number == 1 || @line_number == 100 || @line_number == 1000 ) $1:1/0)):2

另请参阅此问题的答案

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

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