如何使用 gnu plot 绘制带有指示方向的矢量的圆?

How to use gnu plot to plot circles with vectors indicating direction?

我有这样一个数据文件:

1  1.680  24.250 0.1 0.0  1.830  24.250
2  6.330  24.860 0.1 30.0  6.460  24.935
3  9.440  24.320 0.1 60.0  9.515  24.450
4  12.110  25.790 0.1 -30.0  12.240  25.715

代表4个相同半径为0.1米的圆。格式为:

number x y radius angle offset-x offset-y

objective是在指定的角度在offset-x和offset-y处绘制4个带箭头的圆圈,并让所有箭头的长度相同。我已经检查了很多例子,但无法从中提取我想做的事情。

这是我的 gnu 情节代码:

#!/usr/local/bin/gnuplot
reset
set term pngcairo dashed font "Times,20" size 1920,1080

set loadpath "/Users/woo/.gnuplotting"
load 'default.plt'

set output 'avatars.png'

set grid
set xlabel "X" font "Times Bold,20"
set ylabel "Y" font "Times Bold,20"
set key outside right top vertical

xf(theta) = 0.1*cos(theta/180.0*pi)
yf(theta) = 0.1*sin(theta/180.0*pi)

plot "plot_file.txt" using 2:3:4 with circles, \
  "plot_file.txt" using 6:7:xf(5):yf(5)  \
   with vectors head size 0.1,20,60 filled

0.1 是为了减小向量的大小。我得到了圆圈,但偏移量不一样,应该是。据推测,我的偏移量半径为 0.15 米。 但是,所有矢量的长度都在增加,并且没有指向指定的方向。

我感觉解决方案很明显,但我找不到。

主要问题是向量的 using 部分:

xf(theta) = 1.0*cos(theta/180.0*pi)
yf(theta) = 1.0*sin(theta/180.0*pi)

plot "plot_file.txt" using 2:3:4 with circles,\
     "plot_file.txt" using 6:7:(xf()):(yf()) \
      with vectors head size 0.1,20,60 filled

对于表达式,写</code>而不是<code>5。此外,表达式应放在括号中:using 6:7:(xf()):(yf()) 而不是 6:7:xf(5):yf(5).

我也将 0.1 更改为 1.0,因为我想要单位向量。

这是结果:

每个箭头实际上都是相同的长度,但它看起来并不那样,因为 x 轴和 y 轴的缩放比例不同。要使两个轴具有相同的缩放比例,请执行

set size ratio -1

这是结果: