2012-05-30 37 views
6
使用的gnuplot

我試圖創建一個具有以下數據的疊加柱狀圖:用於堆放直方圖

8.01 1 5 1 
8.02 3 5 1 
8.03 4 4 1 
8.04 3 4 1 
8.05 1 2 1 

我試圖從第四例子,此刻我使用這個適應的腳本:

set title "Test" 
set key invert reverse Left outside 
set key autotitle columnheader 
set style data histogram 
set style histogram rowstacked 
set style fill solid border -1 
set boxwidth 0.75 

plot 'test.dat' using 2:xtic(1), '' using 2 title 'Col1', '' using 3 title 'Col2', '' using 4 title 'Col3' 

我不知道的部分是using 2:xtic(1)。我知道這使得它使用xtic值作爲第一列,這正是我想要的。但我不知道using 2部件代表什麼。這是腳本產生什麼樣的截圖:

enter image description here

一切,除了紅酒吧,不應該出現在圖像上的罰款。有人能向我解釋爲什麼它出現以及如何擺脫它?

回答

10

using 2意味着gnuplot將使用文件中的第二列來繪製數據。如果您正在繪製x數據與y數據的繪圖,則如果x數據在列1中且y數據在列2中,則命令爲plot data using 1:2plot using 2將在y軸上繪製第2列的數據,並且對於每個數據點x座標將加1.

您會注意到綠色和紅色條的大小相同:它們都使用第2列。如果您不想顯示第一個(紅色)條,可以更改plot命令到

plot 'test.dat' using 2:xtic(1) title 'Col1', '' using 3 title 'Col2', '' using 4 title 'Col3' 

使用此命令,xtic標籤將保持不變,第一個bar將不再存在。請注意,數據的顏色將隨着此命令而改變,因爲繪製的第一件物品將是紅色,第二個綠色和第三個藍色。