2
votes

Plotting data of file data.txt from line 1 to 10 in some color say red and next 10 to 20 with other similarly 20 to 30 with different color till 100th row

data.txt file is something like this:

1 1 
2 2
3 3
4 4
5 5
6 6
..
..
..
10 10

1 2
3 4
1 1
..
..
..
..

.
.
.
.

90 90
91 91
..
..
..
100 100
2
@GautamSavaliya the problem has just one line answer I plotted all points using same color but need different color for different row range gnuplot "data.txt" - Adarsh Nair
Can you please try to write in full sentences, with question marks etc.? This is insulting to the reader. - Karl
@Karl I was in a hurry. missed question mark. Is question mark important? - Adarsh Nair
Punctuation is highly important in western languages. The order of words in a sentence changes the meaning completely, so you need to know where it starts and ends. - Karl

2 Answers

1
votes

plot 'aaa.txt' every ::1::10 w p, 'aaa.txt' every ::11::20 w p, ...

UPDATE

worked for me (well, except numbering should go from 0)

plot 'aaa.txt' every ::0::2 w p, 'aaa.txt' every ::3::5 w p

produced following graph

enter image description here

1
votes

If you can structure your data-file to separate every data block with 2 empty lines, you can use feature index with a for loop:

unset key
plot for [i=0:9] 'temp.txt' index i

plot in 10-itemed blocks

(my datafile is 1-10 in every block (1-10, 11-20...), structured with 2-2 empty lines)

If you can't structure your data-file (our you are just lazy ;-) ) you can use only the for loop:

plot for [i=0:9] 'temp2.txt' every ::i*10::i*10+9

(my datafile is 1-10 in every block (1-10, 11-20...) without empty lines)


EXTENSION (according to Karl)

If you can structure your data-file to separate every data block with 1 empty lines, you can use feature index with a for loop

plot for [i=0:9] 'temp3.txt' every :::i::i

(my datafile is 1-10 in every block (1-10, 11-20...), structured with 1-1 empty lines)