2
votes

I would like to skip some points to draw a graph in gnuplot and not connecting lines through missing points.

It is the same problem than : https://superuser.com/questions/440947/in-gnuplot-how-to-plot-with-lines-but-skip-missing-data-points

The gnuplot help says :

set datafile missing "?"

set style data lines

plot '-'

 1 10
 2 20
 3 ?
 4 40
 5 50
 e

plot '-' using 1:2

 1 10
 2 20
 3 ?
 4 40
 5 50
 e

plot '-' using 1:($2)

 1 10
 2 20
 3 ?
 4 40
 5 50
 e

The first plot will recognize only the first datum in the "3 ?" line. It will use the single-datum-on-a-line convention that the line number is "x" and the datum is "y", so the point will be plotted (in this case erroneously) at (2,3).

The second plot will correctly ignore the middle line. The plotted line will connect the points at (2,20) and (4,40).

The third plot will also correctly ignore the middle line, but the plotted line will not connect the points at (2,20) and (4,40).


In order not to connect the points (2,20) and (4,40), we have to put a $ symbol : plot '-' using 1:($2)

I'd like to do the same thing with the following line :

plot using i:xticlabels(1) title columnheader(i)

But it doesn't work (i tried ($i):xticlabels(1) and other things... it doesn't work)

Thank you

1

1 Answers

1
votes

You must use column(i) to select the i-th column. $1 is a shortcut for column(1) but you cannot use $i as shortcut for column(i):

set style data lines
i=2
plot '-' using (column(i)):xticlabels(1) title columnheader(i)
A B
1 10
2 20
3 ?
4 40
5 50
e

enter image description here