2016-10-10 39 views
0

我正在嘗試使用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 

回答

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聲明佔用由冒號分隔六個參數,但你可以讓他們空的默認值。第五個參數是結束點,第三個是起點)

  • 如果您使用-作爲文件中的缺失數據(如您的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