2017-04-02 19 views
0

我有一個小問題。我嘗試創建具有許多行或形狀的gnu情節,但標題在最後一列。在文件示例數據不同形狀的列中的Gnuplot標籤

18:40:03 0.00 K/s 3.65 K/s 0.00 % 0.25 % AA 
18:40:03 0.00 K/s 69.44 K/s 0.00 % 0.05 % BB 
18:40:03  0.40 K/s 0.00 K/s 0.00 % 0.03 % AA 

我gnuplot的代碼

set xlabel "Date\nTime" 
set timefmt "%H:%M:%S" 
set format x "%H:%M:%S" 
set xdata time 
set autoscale xy 
set term png 
set output "io.png" 
plot 'io.log' using 0:8 title 'title', \ 
    '' using 0:8:10 with labels offset 0,char 1 
~ 

但我要創建圖,其中此同一類型(AA)具有從BB CC此相同的顏色或形狀和不同.....

Problem is this same label

回答

1

爲了簡化起見,我們假設輸入數據被存儲在一個文件test.dat,它有以下形式:

1 2 AA 
2 4 BB 
3 6 AA 

然後有幾種可能性基於第三列中標籤的值區分樣式。

一個例如可以調用外部處理(在你的情況標籤「AA」),以篩選出「特殊類型」的記錄,並指定一個特定的風格:

unset key 
set xr [0:4] 
set yr [0:10] 

plot \ 
    '< gawk ''$3=="AA"'' test.dat' using 1:2 w p pt 1, \ 
    '' u 1:2:3 w labels offset 0,char 1 tc rgb 'red', \ 
    '< gawk ''$3!="AA"'' test.dat' using 1:2 w p pt 2, \ 
    '' u 1:2:3 w labels offset 0,char 1 tc rgb 'blue' 

這將產生: enter image description here

另外,爲了區分標籤的只是風格,人們可以直接在gnuplot的過濾個別情況爲:

set terminal png enhanced 
set output 'fig2.png' 

unset key 
set xr [0:4] 
set yr [0:10] 

checkLabel(label)=(label eq 'AA') 
filter(label, val, flag)=(((flag && checkLabel(label))||(!flag && !checkLabel(label)))?val:1/0) 

plot \ 
    'test.dat' using 1:2 w p , \ 
    '' using 1:(filter(stringcolumn(3), $2, 1)):3 w labels offset 0,char 1 tc rgb 'red', \ 
    '' using 1:(filter(stringcolumn(3), $2, 0)):3 w labels offset 0,char 1 tc rgb 'blue' 

其產生: enter image description here