gnuplot: Faulty sensor sometimes reading 0.00 - how to convert them to missing?

前端 未结 1 1186
青春惊慌失措
青春惊慌失措 2021-01-24 03:13

I have a combination RPi/Arduino taking readings from several DHT-22 Humidity/Temperature sensors.

One of the sensors developed a loose wire and has been giving occasi

相关标签:
1条回答
  • 2021-01-24 03:49

    Gnuplot allows you to filter data while plotting:

    gnuplot 'file.dat' using 1:($2 == 0.0 ? 1/0 : $2)
    

    This treats all values of 0 as invalid points and those points are skipped. Depending on the selected plotting style that works, or not: plot ... with lines interrupts a line at an invalid point.

    Since gnuplot version 5.0.6 you can use set datafile missing NaN to have invalid points treated as missing ones, and a line would simply ignore those points:

    $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:

    0 讨论(0)
提交回复
热议问题