gnuplot missing data with expression evaluation
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开发者_StackOverflow社区
e
But I want it to ignore the missing data "?" in such a way that it connects the line (and doesn't break it between 2 and 4).
I triedset datafile missing "?"
,
but in agreement with the online-help it does not connect the lines. The following would, but I cannot use expression evaluation:
plot "-" using 1:2 with lines
1 10
2 20
3 ?
4 40
5 50
e
Any ideas how to connect the lines and use expression evaluation?
Two column data
If you set up a data file Data.csv
1 10
2 20
3 ?
4 40
5 50
you can plot 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 make use of awk.
With a data file Data.csv
1 10 1
2 20 2
3 ? 3
4 40 ?
5 50 5
you can run a script over the data file for each plot like so:
plot "<awk '{if($2 != \"?\") print}' Data.csv" u ($1):($2) w lp, \
"<awk '{if($3 != \"?\") print}' Data.csv" u ($1):($3) w lp
A reference on scripting in gnuplot can be found here. The awk user manual here.
精彩评论