我在Gnuplot中还很陌生,所以很抱歉如果这个问题很愚蠢,但是我还没有找到解决方案。
我有一个具有以下结构的数据文件:
timestep=0
1 -1.367+00 -2.538572773308e-01
2 -1.351097897106e+00 -2.382132334519e-01
3 -1.372764576847e+00 -1.205983667912e-01
4 -1.33451163582e+00 -2.3438654806e-01
5 -2.414239606e+00 -2.683590584894e-01
6 -4.425446031e+00 -3.246530421864e-01
7 -6.438461740e+00 -4.589039346035e-01
...
timestep=1
...
timestep=2
...
因此,对于每个时间步长,迭代次数(我要在x轴上进行计数)都会重新开始。 时间步长很多,所以如果将所有时间步长放在一起,很难看到每一行。 所以问题是:如何绘制仅一个时间步长的线?
每个时间步的迭代次数是不同的。
谢谢
答案 0 :(得分:2)
这个问题看起来像是this one的副本。 不过,我们的想法是分别绘制每个块:
plot for[in=0:2] 'file' index in u 1:2 w lines t columnheader(1)
请注意,您需要使用双引号将每个标头引起来。
如果每个块都需要有单独的输出,则不需要像这样的do for
构造:
do for [i=0:2] {
set output sprintf("%d.png", i)
plot 'file' index i u 1:2 not
}
更新
我已经检查了一次,这是我的最小脚本:
set term png size 800, 600
set output "out.png"
plot for[in=0:1] 'file' index in u 1:2 w lp t columnheader(1)
还有我的“文件”文件:
"timestep=0"
1 0
2 3
3 2
4 1
5 6
"timestep=1"
1 4
2 3
3 9
4 6
5 3
答案 1 :(得分:-1)