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.
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):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With