在 gnuplot 中移动箭头
Shifting an arrowhead in gnuplot
我正在画一条需要有箭头的线。我有结束坐标,但因为那里有一个小球体,所以它应该移动一点点。关于如何在不手动计算新坐标的情况下执行此操作的任何想法(这真的很痛苦)。也许改变箭头定义?
#the arrow with heads that need to be shifted
set style arrow 5 heads filled size screen 0.03,15,45 ls 10
set arrow from 0.0, -1.0, -2.1908902300206643 to 0., 1., 0. ls 10 as 5
#the line itself:
set arrow from 0.0, -1.0, -2.1908902300206643 to 0., 1., 0. nohead ls 3
让我手动计算新坐标:)
假设箭头的二维终点由 a=(ax,ay)
和 b=(bx,by)
给出。包含点 a
和 b
的任何直线的坐标 (rx,ry)
可以根据公式
计算得出
rx(t) = (1-t)*ax + t*bx
ry(t) = (1-t)*ay + t*by
其中 t
是实数。注意r(0)=a
和r(1)=b
,所以原来的箭头可以画成
set arrow from rx(0),ry(0) to rx(1),ry(1)
要缩短(或放大)此箭头,您可以使用相同的指令将 t
的值设置为不同于 0 或 1。例如:
eps=0.1
set arrow from rx(eps),ry(eps) to rx(1-eps),ry(1-eps) #shortened both sides
set arrow from rx(0),ry(0) to rx(1-eps),ry(1-eps) #shortened just the end-point
set arrow from rx(0),ry(0) to rx(1+eps),ry(1+eps) #enlarged just the end-point
我正在画一条需要有箭头的线。我有结束坐标,但因为那里有一个小球体,所以它应该移动一点点。关于如何在不手动计算新坐标的情况下执行此操作的任何想法(这真的很痛苦)。也许改变箭头定义?
#the arrow with heads that need to be shifted
set style arrow 5 heads filled size screen 0.03,15,45 ls 10
set arrow from 0.0, -1.0, -2.1908902300206643 to 0., 1., 0. ls 10 as 5
#the line itself:
set arrow from 0.0, -1.0, -2.1908902300206643 to 0., 1., 0. nohead ls 3
让我手动计算新坐标:)
假设箭头的二维终点由 a=(ax,ay)
和 b=(bx,by)
给出。包含点 a
和 b
的任何直线的坐标 (rx,ry)
可以根据公式
rx(t) = (1-t)*ax + t*bx
ry(t) = (1-t)*ay + t*by
其中 t
是实数。注意r(0)=a
和r(1)=b
,所以原来的箭头可以画成
set arrow from rx(0),ry(0) to rx(1),ry(1)
要缩短(或放大)此箭头,您可以使用相同的指令将 t
的值设置为不同于 0 或 1。例如:
eps=0.1
set arrow from rx(eps),ry(eps) to rx(1-eps),ry(1-eps) #shortened both sides
set arrow from rx(0),ry(0) to rx(1-eps),ry(1-eps) #shortened just the end-point
set arrow from rx(0),ry(0) to rx(1+eps),ry(1+eps) #enlarged just the end-point