Reputation: 167
I have a file in the form
# Line 1
# x y z
x11 y11 z11
x12 y12 z12
....
x1n y1n z1n
( blank row )
.....
# Line N
# x y z
xN1 y11 z11
xN2 y12 z12
....
xNk yNk zNk
If I try to splot such file, gnuplot intended it as a surface, and the result is very awful (because the endpoint of a line is close to the endpoint of next line, not to the first point). How can I plot them as different lines (as every line was in a different file)?
Upvotes: 1
Views: 1127
Reputation: 48390
Each contiguous part of coordinates is called a block
. Two block
s are separated by a single blank row. (Note, that two blank rows separate two data sets which can be accessed with index
).
You can select a certain row for plotting using the every
option:
block = 4
splot 'file.dat' every :::block::block
This selects the fifth block
(the numbering starts at 0
).
To iterate over all available blocks, you can estimate the number of blocks with the stats
command:
stats 'file.dat'
splot for [i=0:int(STATS_blank)] 'file.dat'
Note, that some blanks at the end of the file, which do not separate blocks, are also counted, but that is no problem for the iteration.
You can of course also use the iteration variable i
to select a certain linetype
or linestyle
.
Upvotes: 1