存在空数据时避免连接点

时间:2016-10-10 14:13:48

标签: gnuplot

我正在尝试使用Gnuplot制作折线图。我需要得到类似下面的内容,但有一个例外:

enter image description here

在上面的示例中,您可以看到一条直线,它在空数据上连接两个独立的点。它是跨越'2016-09-27 00:00:00' x 的那个。我希望有一个空的空间而不是那条直线。我怎么能做到这一点?

这是当前的代码:

  set xdata time
  set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 900, 350
  set output filename
  set key off
  set timefmt '"%Y-%m-%d %H:%M:%S"'
  set format x "%Y-%m-%d %H:%M"
  set xtics rotate by -80
  set mxtics 10
  set datafile missing "-"
  set style line 1 lt 2  lc rgb 'blue' lw 1
  set style line 2 lt 2  lc rgb 'green' lw 1
  set style line 3 lt 2  lc rgb 'red' lw 1

  plot\
  fuente using 1:2 ls 1 with lines,\
  fuente using 1:3 ls 2 with lines,\
  fuente using 1:4 ls 3 with lines

1 个答案:

答案 0 :(得分:0)

三个选项:

  • 在数据文件中,在空白处放置一个空行。这会产生您想要的结果,但也会影响该文件中的其他数据。
  • 使用every仅绘制一部分数据并绘制两次,一次到间隙,一次从间隙开始。假设在您的情况下数据点42和43之间出现间隙,那么您可以使用:

    plot\
    fuente using 1:2 ls 1 every ::::41 with lines,\
    fuente using 1:2 ls 1 every ::42   with lines,\
    fuente using 1:3 ls 2 with lines,\
    fuente using 1:4 ls 3 with lines
    

    every语句最多使用以冒号分隔的六个参数,但您可以将它们留空以获取默认值。第五个参数是结束点,第三个参数是起点。)

    < / LI>
  • 如果您使用-表示文件中缺少数据(如set datafile missing "-"所示),则您修改了使用声明以使其生效:

    plot\
    fuente using 1:($2) ls 1 with lines,\
    fuente using 1:3    ls 2 with lines,\
    fuente using 1:4    ls 3 with lines