R:如何画一条带有多个箭头的线? [英] R: how do I draw a line with multiple arrows in it?
本文介绍了R:如何画一条带有多个箭头的线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以帮助我在 R 中绘制带有多个箭头的线条,如下所示:
I was wondering if anyone could help me plot lines in R with multiple arrows in them, like this:
--->--->--->--->
--->--->--->--->
提前致谢!
推荐答案
Simulair to DWin 这是我想到的:
Simulair to DWin this is what I came up with:
arrowLine <- function(x0,y0,x1,y1,nArrow=1,...)
{
lines(c(x0,x1),c(y0,y1),...)
Ax=seq(x0,x1,length=nArrow+1)
Ay=seq(y0,y1,length=nArrow+1)
for (i in 1:nArrow)
{
arrows(Ax[i],Ay[i],Ax[i+1],Ay[i+1],...)
}
}
基本上它在一行中重叠了几个箭头,但确实得到了想要的结果(我假设是直线):
Basically it overlaps several arrows in a line, but does get the desired result (I assume straigth lines):
plot(0:1,0:1)
arrowLine(0,0,1,1,4)
真正棘手的部分是让箭头到达点的边缘而不是中心.需要吗?
The real tricky part comes to getting the arrow to got o the edge of points instead of the center. Is that needed?
这篇关于R:如何画一条带有多个箭头的线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文