Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: Data blocks with different colours

Tags:

gnuplot

I have a data file with multiple blocks in it, e.g.

x1 y1
x2 y2
x3 y3
x4 y4


x1 y1
x2 y2
x3 y3
x4 y4


x1 y1
x2 y2
x3 y3
x4 y4

And I'd like to plot each block to default to a different colour. If each of these block were in a separate text file, this wouldn't be an issue as Gnuplot defaults to doing that. Anyone know how I can get the blocks to each plot in a different colour (preferably regardless of how many blocks I have)?

Thanks.

like image 823
Jean-Luc Avatar asked Feb 27 '14 06:02

Jean-Luc


1 Answers

The number of the data block is available as pseudo-column -2. Together with linecolor variable it gives you what you want:

plot 'data.dat' using 1:2:-2 lc var with lines

With the data file:

1 1
2 2
3 3
4 4


1 2
2 3
3 4
4 5


1 3
2 4
3 5
4 6

you get the result (with 4.6.3):

enter image description here

like image 197
Christoph Avatar answered Oct 30 '22 14:10

Christoph