gnuplot: Connect points even when missing/invalid are inbetween

坚强是说给别人听的谎言 提交于 2019-12-24 06:42:07

问题


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.


回答1:


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:



来源:https://stackoverflow.com/questions/46069413/gnuplot-connect-points-even-when-missing-invalid-are-inbetween

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!