I can't figure how to plot multiple curves which start and ends after every sequence. My sequences repeats itself for "N" times (many) from 1 to 5. I want to plot column2 versus column3 and have a different curve each time column1 (using it as ternary operator) goes from 1 to 5.
In the eample it should come out a graph with 2 curves. The sequence is a variable itself it's not a constant number of points.
for example:
column1 column2 column3
1 1 2 4
2 1 3 6
3 1 5 7
4 1 9 0
5 2 5 7
6 2 8 9
7 3 9 6
8 4 4 3
9 4 2 4
10 4 6 9
11 4 0 0
12 5 7 0
13 5 6 8
14 1 5 2
15 2 3 5
16 3 6 7
17 4 8 3
18 4 2 1
19 4 2 6
20 5 8 9
Linepoints would be the best, but with points it also very good. The colour is not important, there is no need to have a key.
There are a few details unclear and missing from your description, so I'll make assumptions.
in principle, you could plot your split data every ::0::12
and every ::13::19
(line index is zero-based), but I assume the number of lines will be variable and different for each datafile.
you want to plot column2 and column3 versus column1 (but maybe you want to plot column2 versus column3)? I assume the former.
you want to plot with points
. In contrast, with lines
will get more complicated because your data doesn't contain breaks after column1 goes from 5
back to 1
.
you did not specify if your column1 increases from 1
to 5
only twice or maybe N
times?
Generally, often you can adapt your data, so that the plot commands will be easier or in case you cannot or don't want to change the original data, the plotting commands might get a bit more complicated.
Ok, as a starting point to get any further check the following example (with some completed test data):
Script:
### break data into subsets
reset session
$Data <<EOD
1 11.0 21.0
1 11.3 21.3
1 11.6 21.6
1 11.9 21.9
2 12.0 22.0
2 12.5 22.5
3 13.0 23.0
4 14.0 24.0
4 14.3 24.3
4 14.6 24.6
4 14.9 24.9
5 15.0 25.0
5 15.5 25.5
1 16.0 26.0
2 17.0 27.0
3 18.0 28.0
4 19.0 29.0
4 19.4 29.4
4 19.8 29.8
5 20.0 30.0
EOD
set key out reverse Left noautotitle
myColors = "0xff0000 0x00ff00 0x0000ff 0xff00ff"
myColor(col) = (t0=t1, t1=column(col), t1<t0 ? c=c+1 : 0, int(word(myColors,c)))
myTitles = '"column2, 1st" "column2, 2nd" "column3, 1st" "column3, 2nd"'
plot t1=(c=1,NaN) $Data u 1:2:(myColor(1)) w p pt 7 lc rgb var, \
t1=(c=3,NaN) '' u 1:3:(myColor(1)) w p pt 7 lc rgb var, \
for [i=1:4] keyentry w p pt 7 lc rgb int(word(myColors,i)) ti word(myTitles,i)
### end of script
Result:
Addition:
Another trial. I don't know if your provided data is anywhere near to something realistic. If you plot such random data, why do you want to separate it into different curves even with the same color?
Anyway, here is a suggestion for interrupting a curve from continuous data (here additionally continuing with a different color).
The "trick" is to check whether the current value in column1 is smaller than the previous value. If this is the case, change the line color to transparent (e.g. 0xff123456
) otherwise loop between the 3 colors RGB (or take constant color).
The transparent line "trick" has the disadvantage that the first data point in a linespoints plot will miss its point (can be added separately if needed).
Another option would be to introduce an empty line after each sequence in column1 (from 1 to 5). But I assume you don't want to change your 200 MB data file.
Check the example below, but it could well be that I still haven't fully understood what you actually want.
Script:
### break data into several curves
reset session
$Data <<EOD
column1 column2 column3
1 2 4
1 3 6
1 5 7
1 9 0
2 5 7
2 8 9
3 9 6
4 4 3
4 2 4
4 6 9
4 0 0
5 7 0
5 6 8
1 5 2
2 3 5
3 6 7
4 8 3
4 2 1
4 2 6
5 8 9
1 1 2 # some more data added for illustration
2 3 8
3 1 7
EOD
myColors = "0xff0000 0x00ff00 0x0000ff"
myColor(col) = (t0=t1, t1=column(col), t1<t0 ? (c=c+1, 0xff123456) : int(word(myColors,c%3+1)))
set key noautotitle
plot t1=(c=0,NaN) $Data u 2:3:(myColor(1)) w lp pt 7 lc rgb var
### end of script
Result: