不幸的是,您当前的数据文件设置无法做到这一点。every
您可以使用( e
) 关键字制作不连接点的图:
plot for [i=0:NPOINTS-1] 'test.dat' e ::i::i w p
但是,如果您想要连接数据集,这并不是很有帮助,您需要“反转”您的数据。我会使用python
,因为它非常简单:
#pythonscript.py
import sys #allow us to get commandline arguments
#store data as
#[[x1(t=0) y1(t=0),x2(t=0) y2(t=0),x3(t=0) y3(t=0),...],
# [x1(t=1) y1(t=2),x2(t=2) y2(t=2),x3(t=2) y3(t=2),...],
# ...
# [x1(t=N) y1(t=N),x2(t=N) y2(t=N),x3(t=N) y3(t=N),...],
#]
with open(sys.argv[1]) as fin:
data = []
current = []
data.append(current)
for line in fin:
line = line.rstrip()
if line:
current.append(line)
else:
current = []
data.append(current)
#now transpose the data an write it out. `zip(*data)` will give you:
#[(x1(t=0) y1(t=0),x1(t=1) y1(t=1),x1(t=2) y3(t=2),...),
# (x2(t=0) y2(t=0),x2(t=1) y2(t=1),x2(t=2) y2(t=2),...),
# ...
# (xN(t=0) yN(t=0),xN(t=1) yN(t=1),xN(t=2) yN(t=2),...),
#]
for lst in zip(*data):
for dpoint in lst:
print dpoint
print
对我来说,给定输入文件 ( test.dat
):
x1(t=0) y1(t=0)
x2(t=0) y2(t=0)
xn(t=0) yn(t=0)
x1(t=1) y1(t=1)
x2(t=1) y2(t=1)
xn(t=1) yn(t=1)
x1(t=p) y1(t=p)
x2(t=p) y2(t=p)
xn(t=p) yn(t=p)
运行python pythonscript.test.dat
给出:
x1(t=0) y1(t=0)
x1(t=1) y1(t=1)
x1(t=p) y1(t=p)
x2(t=0) y2(t=0)
x2(t=1) y2(t=1)
x2(t=p) y2(t=p)
xn(t=0) yn(t=0)
xn(t=1) yn(t=1)
xn(t=p) yn(t=p)
现在您可以使用andyras 的解决方案绘制它:
plot for [i=0:NP] '< python pythonscript.py data.dat' index i w lp