How to build a line with missing data points in gnuplot

Example:

enter image description here

I want to plot the same as above: a line with some missing data points, which means the line is broken.

How can i do this?

+7
source share
2 answers

It depends on how your data file looks. If you enter an empty space in your data file, it will not connect these neighboring points (this is the easiest way):

consider the following issues:

#datafile 1 2 2 3 4 2 5 3 

and then a script to build it:

  plot 'datafile' u 1:2 w linespoints 

There are other tricks that you can play with missing data: set datafile missing . A good reference for this is the built-in help ( help missing ).

+9
source

For a single graph, use set datafile missing to specify a character string that means the missing value, and the using $ qualifier to ensure that gnuplot leaves a space in the string for the missing value. Various using qualifiers are described in the gnuplot documentation for set datafile missing .

If the column number is specified as a variable, it is a little more complicated. For example, to build multiple columns of a file, you can specify the column number using a variable:

 do for [i=2:10] { plot 'datafile' using ($1):i with lines } 

However, if we try to use the $ syntax, it does not work:

 do for [i=2:10] { plot 'datafile' using ($1):($i) # ERROR! } 

The solution is to use a column function that also leaves spaces for missing values:

 do for [i=2:10] { plot 'datafile' using ($1):(column(i)) with lines } 
0
source

All Articles