sweber
sweber

Reputation: 2976

gnuplot: Connect points even when missing/invalid are inbetween

I have a data file with interleaving data rows from different devices.

Now, I'd like to plot data from one devices with linepoints and use this to filter only the device of interest:

plot 'datafile' using (<someCondition> ? $1 : 1/0):2

Now, gnuplot does not connect the points because there is always some invalid data inbetween.

Is it possible to make gnuplot to connect my points?

By the way: This is a Windows machine, so an external sed/awk/whatever command is no option.

Upvotes: 1

Views: 864

Answers (1)

Christoph
Christoph

Reputation: 48390

Since gnuplot version 5.0.6 you can use set datafile missing NaN to have invalid points treated as missing ones, and drawing with lines or with linespoints simply ignores those points and connects the others

$data <<EOD
12
27
0
23
42
EOD

set multiplot layout 1,2

set title '0.0 invalid'
plot $data using 0:($1 == 0.0 ? 1/0 : $1) with linespoints pt 7 notitle

set title '0.0 invalid but treated as missing'
set datafile missing NaN
replot
unset multiplot

Output with 5.0.6:

enter image description here

Upvotes: 1

Related Questions