Gnuplot: Using “With Lines” in combination with “every”command

本秂侑毒 提交于 2019-12-13 13:28:22

问题


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    

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

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?

Thanks in advance, Jürgen


回答1:


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

With 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


来源:https://stackoverflow.com/questions/19792919/gnuplot-using-with-lines-in-combination-with-everycommand

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!