Gnuplot:使用“带线"结合“每个"命令 [英] Gnuplot: Using "With Lines" in combination with "every"command

查看:52
本文介绍了Gnuplot:使用“带线"结合“每个"命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于gnuplot我只是有一个小问题:

I just have a little problem concerning gnuplot:

我有一个巨大的数据文件,其中包含几个数据块,我只想绘制每个块第一行中包含的数据.因此,我使用了每一个命令:

I have a huge data file, containing several blocks of data and i just want to plot the data contained in the first line of each block. Thus, i use the every command:

plot "../path/to/data.dat" u 1:2 every ::1::1    

现在的问题是,我想使用带线",但是gnuplot不会将带线的绘图数据连接起来.

The Problem now is, that i want to use "with lines", but gnuplot doesn't join the plotted data with lines.

我可以想到两种解决方案: 首先是将终端类型设置为表",然后绘制此新表数据文件. 第二种方法是在plot命令中使用awk,这样我就可以通过awk提取原始数据文件中每个块的第一行数据.

There are two solutions I can think of: The first would be setting the terminal type to "table", and then plotting this new table data file. The second would be using awk within the plot command, such that I extract via awk the first line of data of each block in the original data file.

但是我很确定,必须有更简单的解决方案?

But I'm quite sure, there have to be much easier solutions?

预先感谢, 于尔根

推荐答案

我认为awk解决方案已经非常简单

I think awk solution is very simple already

plot "<awk -v p=1 'n==p; NF{n++} !NF{n=0}' test.dat" w l, \
     "test.dat" every ::1::1

使用 test.dat :

1
2
3
4

5
6
7
8
9

10
11
12
13
14

15
16
17
18
19

20
21
22
23
24

这篇关于Gnuplot:使用“带线"结合“每个"命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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