改变箭头的箭头()
我想知道是否可以更改用 arrows()
绘制的箭头的箭头。我查看了文档,但我发现我可以更改行尾但不能更改箭头?
plot(c(1:10))
arrows(0,0,10,10)
如有任何帮助,我们将不胜感激:)
i wonder if it is possible to change the arrowhead of an arrow drawn with arrows()
. I looked through the documentation but all I found is that I can change the end of a line but not of an arrow?
plot(c(1:10))
arrows(0,0,10,10)
Any help is appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如
?arrow
中所述,您可以使用length
和angle
来更改标准箭头的外观。使用lwd
你可以改变粗细,就像lines()中一样。lty
也可以工作,尽管结果通常不太好。一整套例子:
as explained in
?arrow
, you can uselength
andangle
to change the appearance of standard arrows. Withlwd
you can change the thickness, exactly like in lines(). Alsolty
works, although the result is often not exactly nice.A whole set of examples :
Karline Soetaert 的包
shape
对于此目的很有用:默认是一个填充的、弯曲的箭头,看起来很漂亮:
Gotta love CRAN!
Karline Soetaert's package
shape
is useful for this purpose:The default is a filled, curved arrowhead that's pleasant to look at:
Gotta love CRAN!
如果其他答案无法让您使用 arrows 函数对箭头进行足够的控制,您可以使用
TeachingDemos
包中的函数my.symbols
。这允许您创建自己的自定义箭头并绘制它们。同一包中的函数
ms.arrows
显示了执行此操作的一种方法:您可以修改该函数(或其他ms.*
函数)以创建任何类型的您想要的箭头,然后使用 my.symbols 来绘制它们。编辑
这是一个请求的示例:
它使用
xspline
函数绘制一个以弧形背面作为箭头的三角形。可以修改这些点以获得不同形状的箭头,或者可以对形状使用其他方法。If the other answers don't give you enough control of your arrows using the arrows function, you can use the function
my.symbols
, fromTeachingDemos
package. This allows you to create your own custom arrows and plot them.The function
ms.arrows
, in the same package, shows one method of doing this: you can modify that function (or otherms.*
functions) to create any type of arrow you want, and later usemy.symbols
to plot them.Edit
Here is an example as requested:
This uses the
xspline
function to draw a triangle with a curved back as the arrowhead. The points can be modified to get a different shaped arrowhead, or another method can be used for the shape.