【问题标题】:Gnuplot re Plotting lines after restart countGnuplot re 在重新启动计数后绘制线条
【发布时间】:2018-10-14 11:48:24
【问题描述】:

我是 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 轴上)重新启动。 会有很多时间步,所以如果我将所有时间步绘制在一起,很难看到每一行。 所以问题是:我如何绘制一个时间步的线?

每个时间步的迭代次数不同。

谢谢

【问题讨论】:

标签: file gnuplot


【解决方案1】:

这个问题看起来与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

输出必须如下所示:

【讨论】:

  • 不幸的是....gnuplot> plot for[in=0:2] 'file' index in u 1:2 w lines t columnheader(1) ^ invalid expression
  • @federicorovere 你能检查一下更新后的答案吗?
【解决方案2】:

我认为您可以使用plot <filename> every,更多详细信息here 和另一个stackoverflow 描述here

这样你就可以选择不只绘制一个时间步长;但你可以选择每隔两个时间步或每隔三个时间步说一次。

【讨论】:

  • every 在这里没有帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-02
  • 1970-01-01
  • 1970-01-01
  • 2020-09-05
相关资源
最近更新 更多