2014-01-07 25 views
6

我有一個數據文件,其中包含2列,其中包含名稱和值。使用數據文件中的文本列作爲gnuplot中的點標籤

foo 0.1 
bar 0.2 
fff 0.4 
bbb 0.7 

我想繪製這個並註釋數據點旁邊的文本條目。

我試圖

plot 'file' using 1:2 with labels 

,但沒有奏效。我想問題是,我必須依靠gnuplot只使用第二列y和等距x軸。

+0

座標改爲:http://stackoverflow.com/questions/23177716/in-gnuplot-how-to-label-each-point-in-the-plot-with-its-coordinates –

回答

8

你可以做這樣的事情

plot 'file' using 0:2 title 'title', \ 
    '' using 0:2:1 with labels offset 0,char 1 

這將第一常繪製數據,然後在頂部的標籤,通過一個字符偏移了繪製。 0列是虛擬列,它給出數據的索引 - 第一個數據點爲0,第二個數據爲1,等等。

另一種方法是使用直方圖進行繪圖。

+2

對於標籤繪圖樣式,您可以使用0:2和標籤偏移量0,字符1標題'標題''來指定'offset':'plot'文件'。這樣做的好處是,你可以在'character'單位中給出偏移量。 – Christoph

+0

優秀點 - 我相應地更新了我的答案。 – andyras

相關問題