Gnuplot missing expression evaluation data

I want to use the plot command in gnuplot with expression evaluation, i.e.

 plot "-" using ($1):($2) with lines 1 10 2 20 3 ? 4 40 5 50 e 

But I want him to ignore the missing data "?" so that it connects the line (and does not break it between 2 and 4).
I tried set datafile missing "?" but in accordance with the online help it does not connect the lines. The following would be, but I cannot use expression evaluation:

 plot "-" using 1:2 with lines 1 10 2 20 3 ? 4 40 5 50 e 

Any ideas on how to connect strings and use expression evaluation?

+2
source share
1 answer

Two column data

If you have configured the Data.csv data Data.csv

 1 10 2 20 3 ? 4 40 5 50 

you can create your data with connected lines using

 plot '<grep -v "?" Data.csv' u ($1):($2) w lp 

More than two column data

For more than two columns, you can use awk.
With data file Data.csv

 1 10 1 2 20 2 3 ? 3 4 40 ? 5 50 5 

you can run the script on the data file for each chart as follows:

 plot "<awk '{if($2 != \"?\") print}' Data.csv" u ($1):($2) w lp, \ "<awk '{if($3 != \"?\") print}' Data.csv" u ($1):($3) w lp 

Link to scripts in gnuplot can be found here here . The awk user guide is here .

+2
source

Source: https://habr.com/ru/post/1501464/


All Articles