2016-10-22 89 views
0

我想在gnuplot的一個splot內繪製虛線下面的代碼4.6 PATCHLEVEL 4:gnuplot的:在splot虛線的變化密度

set terminal "pdfcairo" enhanced dashed size 15,10 
set pm3d map 
set output "test.pdf" 
splot 'map.dat' using 1:($2/1000):3 notitle, \ 
    'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \ 
    'line2.dat' using 1:($2/1000):1 notitle with lines ls 2 
unset output 

熱圖的作品也是如此line1.dat 。但是,第二行看起來很穩固。不同之處在於line1.dat有70個條目,line2.dat有900個。第二行有兩個點之間的跳轉,並且在那裏是虛線。

有人知道我如何改變網點密度,以便整條線點綴。更改原始數據文件不是一個選項。

感謝你的幫助,

不一

編輯:

一個解決辦法,我發現是

splot 'line2.dat' every ... 

但可以在數據跳得到unconvenient。

回答

1

命令(s)plot 'line.dat' with lines第一重複數據點,然後連接使用與所述相應線型線數據點。如果數據點彼此太靠近,則在使用虛線樣式時,沒有空間可用於某些間隙。

要顯示虛線/虛線,您可以嘗試用函數替換點或減少點數。

  • 嘗試用虛線代替虛線。 Linestyle和linecolor可以獨立設置:splot 'line.dat' with lines ls 0 lc 2。這種方法900點可能太多了。

  • 擬合一個函數是可行的,但可能很難找到合適的函數。

  • every選項可減少點數。

  • 減少點數的另一種方法是使用smooth選項對點進行插值。這需要一個臨時文件和工作原理如下:

    # [prepare plot] 
    set samples 100 
    set table "line2.dat.tmp" 
    plot 'line2.dat' using 1:($2/1000) smooth mcsplines with lines ls 2 
    unset table 
    
    set terminal "pdfcairo" enhanced dashed size 15,10 
    set pm3d map 
    set output "test.pdf" 
    
    # [plot] 
    splot 'map.dat' using 1:($2/1000):3 notitle, \ 
        'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \ 
        'line2.dat.tmp' using 1:2:1 notitle with lines ls 2 
    
    unset output 
    

在[準備劇情]部分創建「line2.dat.tmp」,其中包含的數據點插值line2.dat的臨時文件。你必須玩set samples以獲得合適的分數。在這個例子中,我們有100個等距點,而不是距離不同的900個點。 選項smooth mcsplines保留了原始數據點的單調性和凸性,請參見gnuplot shell中的help smooth mcsplines

在[plot]部分中,原始的「lines2.dat」被內插數據替代。

如果原始數據足夠平滑,以便將900個點替換100個點不會跳過重要信息,則此方法有效。也許你想在一張圖中同時繪製「lines2.dat」和「lines2.dat.tmp」來比較它們。

+0

謝謝你的幫助。對於數據跳轉,我使用了三個「每個」(第一部分,第一部分正確跳轉,第二部分跳轉)。 – noes

0

用戶的every鍵字,這樣的:

'line2.dat' every 20 using 1:($2/1000):1 notitle with lines ls 2