Gnuplot-用户-错误:“所有点y值未定义!”

时间:2019-02-20 02:06:44

标签: gnuplot

这是我的程序。我正在尝试绘制格式对我来说合适的数据。 Gnuplot拒绝绘制数据,称“ y值未定义”。我在做什么错了?

set output "snowData.png"
set title  "Data from Weather Station Yard"
set xdata time 
set timefmt "%H:%M"
set format x "%H"
set xrange [00:24]
set xtics  
set xlabel "Time(hrs)"
set ylabel "Water Content(inches)" tc lt 1      
set y2label "Temperature Deg F" tc lt 2
set grid
#set yrange  [0:2]
#set y2range [-20:80]
#set autoscale y2
set ytics 1 nomirror tc lt 1 
set y2tics 10 nomirror tc lt 2      #MUST set y2tics to view y2label

plot "logSnow.dat" using 1:2 title "Water Content(inches)" with linespoints linetype 1,
\"logSnow.dat" using 1:3 title "Temperature" with linespoints linetype 2    

Here is my data:
2019:02:20:10:55 -0.01,70.14,3.90
2019:02:20:11:26 -0.01,70.59,3.90
2019:02:20:11:57 -0.01,70.36,3.90

1 个答案:

答案 0 :(得分:1)

两个问题:

  1. 您的数据以逗号分隔。所以,你错过了一行

    set datafile separator ","

  2. xrange需要一个时间字符串,格式为"%H:%M"

    set xrange ["00:00":"24:00"]

与此有关,它应该可以工作。

以下代码给出了下图(gnuplot 5.2.5):

### plotting time data
reset session

$Data <<EOD
2019:02:20:10:55,-0.01,70.14,3.90
2019:02:20:11:26,-0.01,70.59,3.90
2019:02:20:11:57,-0.01,70.36,3.90
EOD

set datafile separator ","
set xdata time 
set timefmt "%Y:%m:%d:%H:%M"
set format x "%H"
set xrange ["2019:02:20:00:00":"2019:02:20:24:00"]

plot $Data u 1:2 w lp lt 1 ti "Water Content(inches)" ,\
     $Data u 1:3 w lp lt 2 ti "Temperature"
### end of code

enter image description here

相关问题