2016-09-19 118 views
1

我想在單個圖像中繪製不同的線條。每行都保存在一個不同的純文本文件中,它具有:x | y |深度。因此,我寫這個文件命名爲「plot_vg」:Replot not working on gnuplot

set term pngcairo size 1000,8005 

list = system('ls') 
i = 1 

set output 'image.png' 

do for [file in list] { 
if (file ne 'image.png') { 
    if (file ne 'plot_vg') { 
     if (file ne '..') { 
     if (i==1) { 
      i=0 
      plot sprintf('%s',file) using 1:2:3 with lines notitle 
     } else{ 
      replot sprintf('%s',file) using 1:2:3 with lines notitle 
     } 
     } 
    } 
} 
} 

我的問題是,在年底,保存的圖像僅僅是最後的重製的,而不包括行的其餘部分。我已經看到它進入了良好的循環,它有1個陰謀,然後,其餘的是replots。如果我從術語中打開gnuplot,然後寫第一個陰謀,然後重新排序,則顯示的圖像就是我想要的。這裏的錯誤在哪裏?

我嘗試了這裏的第一個選項Gnuplot - Using replot with png terminal但我得到一個空白圖像文件。

回答

1

做過濾已經當你閱讀的文件列表,然後用plot for [file in list]...迭代:

set term pngcairo size 1000,8005 

list = system("ls | grep -v 'image.png\|plot_vg'") 

set output 'image.png' 

set style data lines 
unset key 
plot for [file in list] file using 1:2 

如果你的數據文件遵循某種模式,你也可以使用類似

list = system("ls *.txt") 

還要注意,一個簡單的plot with lines只使用兩列。