0

I am quite new in Gnuplot, so sorry if the question could be silly, but i have not found the solution yet.

I have a data file with this structure:

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
...

So for every timesteps the count of iterations (what i want on x axis), restarts. There will be many time steps, so if I plot all the timesteps together it is difficult to see every lines. So the questions is: how can i plot the line of just one timestep?

The number of iterations of every time step is different.

Thanks

federico rovere
  • 153
  • 1
  • 7
  • Possible duplicate of [Multiple data blocks in a single file and a single plot + Markers for each block](https://stackoverflow.com/questions/36658283/multiple-data-blocks-in-a-single-file-and-a-single-plot-markers-for-each-block) – Bracula Oct 16 '18 at 02:17
  • See Ethan's answer https://stackoverflow.com/a/52881511/2604213 which uses a new feature from the recent 5.2.5 release. – Christoph Oct 18 '18 at 21:23

2 Answers2

2

This question looks like a duplicate of this one. Nevertheless, the idea is to plot every block separately:

plot for[in=0:2] 'file' index in u 1:2 w lines t columnheader(1)

Note, that you need to wrap every header using double quotation marks.

If you need to have a separate output for every block, than you need a do for construction looking like this:

do for [i=0:2] {
set output sprintf("%d.png", i)
plot 'file' index i u 1:2 not
}

UPDATE

I've checked it one more time, here is my minimal script:

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)

And my "file" file:

"timestep=0"
1 0
2 3
3 2
4 1
5 6



"timestep=1"
1 4
2 3
3 9
4 6
5 3

The output has to look like this: enter image description here

Bracula
  • 335
  • 1
  • 3
  • 14
-1

I think you can use plot <filename> every, more details here and another stackoverflow description here.

That way you can choose to plot not just one timestep; but say every second timestep, or every third as you choose.