R:如何在其中绘制带有多个箭头的线? [英] R: how do I draw a line with multiple arrows in it?

查看:115
本文介绍了R:如何在其中绘制带有多个箭头的线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以帮助我在R中绘制带有多个箭头的线条,如下所示:

I was wondering if anyone could help me plot lines in R with multiple arrows in them, like this:

---> ---> ---> --->

--->--->--->--->

提前谢谢!

推荐答案

Simulair到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆