2015-01-12 229 views
2

經過兩天的試驗和錯誤,我在這裏尋求幫助,因爲我完全失去了gnuplot。 我只需要用不同的顏色顯示幾個數據集,並命名列。 下面是結果:每個數據集不同的顏色

result

第一個問題:在圖中的線具有不同的顏色,但是在標題的顏色是相同的。 第二個問題:如果我取代 「IDX」 經柱(-2)的情節主線之後(即:

datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(column(-2)) with vectors filled head size screen 0.008,145 lc palette z title sprintf("dataset %d", column(-2)) 

我有了這個輸出

second result

在我看來IDX和列(-2)應該等於 這裏是gnuplot的腳本的縮短版(我認爲最關鍵的部分):

stats datafile every ::2 
set palette maxcolors 3 
set palette defined (0 'green', \ 
         1 'red', \ 
         2 'blue') 

set key autotitle columnhead 
set cbrange[0:STATS_blocks-1] 

plot for [idx=0:STATS_blocks-1] \ 
    datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(idx) with vectors filled head size screen 0.008,145 lc palette z title sprintf("dataset %d", idx) 

我的DA TA格式包括2個數據集,看起來像這樣(我已經刪除了一些數據,更短):從克里斯托夫消息後

packetid|time_delta|ip4src|ip4dst|ip6src|ip6dst|mptcpstream|tcpstream|subtype|tcpseq|mapping_ssn|mapping_length|mapping_dsn|ssn_to_dsn|dataack 
2|0.000000000|192.168.1.1|192.168.1.2|||0|0|0|0||||| 
5|0.000067000|192.168.1.1|192.168.1.2|||0|0|2|1|1|20|0|| 
6|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|21|21|20|20|| 
8|0.000064000|192.168.1.1|192.168.1.2|||0|0|2|41|41|20|40|| 
9|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|61|61|20|60|| 

packetid|time_delta|ip4src|ip4dst|ip6src|ip6dst|mptcpstream|tcpstream|subtype|tcpseq|mapping_ssn|mapping_length|mapping_dsn|ssn_to_dsn|dataack 
2|0.000000000|192.168.1.1|192.168.1.2|||0|0|0|0||||| 
5|0.000067000|192.168.1.1|192.168.1.2|||0|0|2|1|1|20|0|| 
6|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|21|21|20|20|| 
8|0.000064000|192.168.1.1|192.168.1.2|||0|0|2|41|41|20|40|| 
9|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|61|61|20|60|| 

編輯:我還有一個問題,但根據您的一個修改後DVICE(線型0不存在,所以我重新索引了一下):

set linetype 1 lw 3 pt 3 lc rgb "red" 
set linetype 2 lw 3 pt 3 lc rgb "green" 

... datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(idx+1) with vectors filled head size screen 0.008,145 lc variable title sprintf("Mappings from dataset %d", idx) 

標題箭頭(而不是紅色和綠色)都在黑: 3rd result

回答

2

與012的問題(以及linecolor variable)的方法是,linecolor對於單個圖可能會有所不同。當所有點的顏色規格不變時,Gnuplot不考慮特殊情況。

有正確的鑰匙,你必須使用lc idx與循環索引idx

plot for [idx=0:STATS_blocks-1] \ 
datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length" with vectors filled head size screen 0.008,145 lc idx+1 title sprintf("dataset %d", idx) 

關於column(-2) VS idx:使用column(-2)using語句不能正常工作。我認爲這樣做會給出錯誤。

+0

感謝您提供寶貴的意見,它提供了我從未在其他地方找到的2條信息,並且我認爲我不會這樣做。儘管根據您的建議進行修改後,我仍然遇到問題。請參閱編輯 – mattator

+0

Ups,對不起。當然,'lc variable'與'lc palette'具有相同的問題,線條顏色可能會在一個繪圖中變化。由於您正在循環,請改用'lt idx'。我馬上更新答案。 – Christoph

+0

確實。現在起作用了。再次感謝 ! – mattator

相關問題