2013-05-14 66 views
0

下面是一個生成單個2D矢量的小腳本,我希望將座標放在箭頭的任一端,以便在查看時更清晰。如何用gnuplot中的座標標記矢量箭頭的末端?

set mxtics 5 
set mytics 5 
set xzeroaxis 
set yzeroaxis 
plot[y=-10:10][x=-10:10] "file.dat" using 1:2:3:4 with vectors filled head lw 3 notitle 

,這裏是我的file.dat

1 -3 -3 2 

我一直在尋找永遠和我似乎無法弄清楚如何。這是我第一次使用gnuplot,所以它不容易。

回答

1

我不知道一種方法來做到這一點automagically,但這裏是一種解決方法。首先,我修改數據文件與座標添加標籤:

1 -3 -3 2 "(1,-3)" "(-2,-1)" 

然後我plot with labels和手動調整偏移,使它看起來不錯:

plot[y=-10:10][x=-10:10] 'file.dat' using 1:2:3:4 with vectors filled head lw 3 notitle, \ 
'' using 1:2:5 with labels offset 3,0, \ 
'' using 3:4:6 with labels offset 0,-4 

enter image description here

當然,你可以跳過花哨的繪圖命令,只需用座標手動放置標籤即可。

+0

我滿足於使用標籤手動添加座標......但我該怎麼做? – agent154

+0

'在圖形x,y'上設置標籤X「文本」,其中'X'是一個可選的數字標籤。你可以在gnuplot控制檯上輸入'help set label'來獲得更多信息。 – andyras