使用gnuplot绘制多个块数据的相同线号
我有一个具有以下结构的数据文件使用gnuplot绘制多个块数据的相同线号,gnuplot,Gnuplot,我有一个具有以下结构的数据文件 block1: line 1 line 2 line 3 ..... block2: line 1 line 2 line 3 ...... block3: ..... 要仅绘制block2,我使用以下命令 plot 'file' u x1:x2 every :::2::2 w l 如何在plot命令上仅收集每个块的第1行?我的猜测是,因为数据点来自不同的块,它们由一
block1: line 1
line 2
line 3
.....
block2: line 1
line 2
line 3
......
block3: .....
要仅绘制block2,我使用以下命令
plot 'file' u x1:x2 every :::2::2 w l
如何在
plot
命令上仅收集每个块的第1行?我的猜测是,因为数据点来自不同的块,它们由一条空行分隔。由空线分隔的数据点不使用“with lines”连接
尝试以下操作:将所需数据写入新表,如下面的示例(gnuplot 5.2.5)
作为额外的提示。当我使用命令
plot'file'ux1:x2 every::3::3wp
时,我得到一个输出。它在单个绘图上绘制每个区块的第3行?但是如果我将选项wp
更改为wl
则不会显示任何内容。看来这个问题也被报道了,谢谢你的回复。还是有些不理解。你能解释一下这两条指令吗?0:3:4
和::0::0
?因为它并不复杂,我也在,我正在循环浏览许多相同类型的文件。我正在使用集合表“name\u I.dat”
的文本文件,其中我使用sprintf(“name\u%d”,I)
将name\u I.dat
生成为do for
循环。有没有一种方法可以对看起来像$DATAi
(参考您的代码)的东西执行相同的操作。我不知道你的数据到底是什么样子的,所以我假设了一些东西。0是gnuplot check帮助pseudcolumns
中的“伪列”:0::0是每个块的第一个数据行,请检查help every
。“诀窍”是将所需数据绘制到新表(即数据块)中。在我的测试数据示例中,plot$data u 3:4 every::0::0 with table
和更高版本的plot$Data2 u 1:2 w lp
也可以使用。如果要使用多个文件执行此操作。。。见我答案中的加法。
### plot values of different blocks connected with lines
reset session
set colorsequence classic
$Data <<EOD
# block line xvalue yvalue
0 0 1 0
0 1 2 1
0 2 3 2
0 3 4 3
1 0 5 10
1 1 6 11
1 2 7 12
1 3 8 13
2 0 9 20
2 1 10 21
2 2 11 22
2 3 12 23
EOD
set table $Data2
plot $Data u 0:3:4 every ::0::0 with table
unset table
print $Data2
plot $Data u 3:4 w lp,\
$Data2 u 2:3 w lp
### end code
### plot every Nth line of all blocks of several systematic files
reset session
FileCount = 2 # number of files
Col1 = 1 # e.g. column of x value
Col2 = 2 # e.g. column of y value
N = 0 # N=0 is first line of each datablock, N=1 second line, etc...
set print $EveryNthLineFromAllBlocksOfAllFiles
do for [i=1:FileCount] {
FILE = sprintf("name_%d.dat",i)
set table $EveryNthLine
plot FILE u Col1:Col2 every ::N::N with table
unset table
print $EveryNthLine
}
set print
print $EveryNthLineFromAllBlocksOfAllFiles
plot $EveryNthLineFromAllBlocksOfAllFiles u 1:2 w lp
### end code