Adarsh Nair
Adarsh Nair

Reputation: 390

Plot file data in gnuplot using different colors

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

Upvotes: 2

Views: 1669

Answers (2)

Tom Solid
Tom Solid

Reputation: 2344

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)

Upvotes: 1

Severin Pappadeux
Severin Pappadeux

Reputation: 20080

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

Upvotes: 2

Related Questions