gnuplot缺少具有表达式评估的数据 [英] gnuplot missing data with expression evaluation
问题描述
我想在gnuplot中使用plot
命令进行表达式评估,即
plot "-" using ($1):($2) with lines
1 10
2 20
3 ?
4 40
5 50
e
但是我希望它忽略丢失的数据?"以这种方式连接线路(并且不会在2到4之间断开).
我尝试了set datafile missing "?"
,
但与在线帮助一致,它不连接线路.可以,但是我不能使用表达式求值:
plot "-" using 1:2 with lines
1 10
2 20
3 ?
4 40
5 50
e
有什么想法如何连接和使用表达式求值?
两列数据
如果您设置数据文件Data.csv
1 10
2 20
3 ?
4 40
5 50
您可以使用以下连接线绘制数据
plot '<grep -v "?" Data.csv' u ($1):($2) w lp
多于两列的数据
对于两个以上的列,您可以使用 awk .
使用数据文件 Data.csv
1 10 1
2 20 2
3 ? 3
4 40 ?
5 50 5
您可以在每个图的数据文件上运行脚本,如下所示:
plot "<awk '{if($2 != \"?\") print}' Data.csv" u ($1):($2) w lp, \
"<awk '{if($3 != \"?\") print}' Data.csv" u ($1):($3) w lp
可以在此处找到有关gnuplot中脚本编写的参考. awk 用户手册此处.>
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 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 tried set 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.
这篇关于gnuplot缺少具有表达式评估的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!