Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot - plot different blocks with different color

Tags:

plot

gnuplot

I have a data like this in a file.dat

2 2
5 5
7 3

100 102
130 80
116 134

-40 -100
-50 -60
-61 -58

I would want to plot each block in different color,

There is no restriction that a specific color, but just some visually different color.

I tried with linetype like this:

for [IDX=0:2] 'file.dat' i IDX u 1:2 with linespoints linetype IDX

it plots all the blocks with different color and obviously only last one is visible.

So what is the right way to do this?

like image 416
Adorn Avatar asked Jan 13 '16 06:01

Adorn


1 Answers

That is the right way, but you must have two blank lines in order to access different blocks with index.

And, you should start at linetype 1, because linetype 0 is a special linetype for the grid lines:

2 2
5 5
7 3


100 102
130 80
116 134


-40 -100
-50 -60
-61 -58

And the plot command

plot for [IDX=0:2] 'file.dat' index IDX u 1:2 with lp lt IDX+1
like image 191
Christoph Avatar answered Oct 05 '22 17:10

Christoph