2014-02-12 13 views
1

讓我只想說,我是新來GNUPLOT ... 試圖從文件繪製:gnuplot的:xtic顯示的數據元素的每一個給定數量的

"Dataset " "Min_sup (%)" Itemsets "Rules " "Exec_time (s)" 
Giorno_1 0.1 16392 260337 15.23 
Giorno_1 0.2 9719 155963 11.96 
Giorno_1 5.0 275 2495 6.43 
Giorno_2 0.1 15023 212058 14.14 
Giorno_2 0.2 8503 115766 14.62 
Giorno_2 0.4 2962 43710 12.90 
Giorno_2 0.8 1603 17514 10.53 
Giorno_2 1.0 1223 14701 9.96 

我想用爲x軸繪製的「Min_sup」列和「數據集」列。問題如下:當您看到「數據集」列中的值有重複,我只想在圖中顯示一次。

所以基本上我正在尋找一種方法來選擇何時繪製x2tics。

Link to the graph

我使用的gnuplot的腳本是:

set style data histograms 
set grid 
set terminal png nocrop enhanced font verdana 12 size 1024,768 
set output "graph.png" 
set xtics norangelimit 
set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0 
set x2tics ("dataset1" "Giorno_1","dataset2" 2,"dataset3" 3,"dataset4" 4,"dataset5" 5,"dataset6" 6) 
set x2tics scale 10 
set xlabel "Minimum support in %" 
set ylabel "# of " 
set style fill transparent solid 0.6 noborder 
set datafile separator " " 
plot 'prova.dat' using 4:xtic(2):x2ticlabels(1) title col , \ 
'prova.dat' using 3:xtic(2):x2ticlabels(1) title col 

回答

3

這是一個有點棘手做到這一點。基本上,您必須保存當前行和前一行的「數據集」值並進行比較。如果它們相同,則不要設置新的x2ticlabel,否則將其用作新標籤。

的值存儲與using命令:

s1 = '' 
s2 = '' 
plot 'prova.dat' using (s2 = s1, s1 = stringcolumn(1), $4):... 

這裏,s2被分配的s1的值,因此,保持前一行的值。然後,s1被分配第一列的字符串值。用$4,使用第四列。這與比較無關,而是使用聲明的「正常」部分(using 4using ($4)幾乎相同)。

的檢查是在x2ticlabel函數完成:

x2tic(s1 eq s2 ? 1/0 : s1) 

這使用了可變s1的值作爲x2ticlabel如果s1s2是相等的。否則它使用1/0。有了這個,你會得到一些類似Tic label does not evaluate as string!的警告,但這是你想要的。

最後,我刪除了從腳本中一些默認設置:

set terminal png nocrop enhanced font verdana 12 size 1024,768 
set output "graph.png" 

set style data histograms 
set grid 
set xtics nomirror rotate by -45 
set x2tics left scale 10 
set xlabel "Minimum support in %" 
set ylabel "# of " 
set style fill transparent solid 0.6 noborder 

s1=''; s2=''; 
plot 'prova.dat' using (s2 = s1, s1 = stringcolumn(1), $4):xtic(2):x2tic(s1 eq s2 ? 1/0 : s1) title col , \ 
'prova.dat' using 3 title col 

給出(與4.6.3):

enter image description here

相關問題