R绘图箭头的类型和大小

5

我正在尝试在基础R绘图上绘制箭头。 我希望箭头头部为一个小等边三角形。 我希望 arrows 中的 arr.type 参数可以允许选择小箭头,但是似乎并不是这样。

arrows(as.Date('1-Feb-15', "%d-%b-%y"), 50, as.Date('1-May-15', "%d-%b-%y"), 50, col = 'dark orange', lwd=5, arr.type = 'simple', arr.width=3)

有没有简单的方法使箭头更小?
2个回答

9

我不知道如何使用 arrows 命令绘制带填充箭头的箭头。但是,您可以使用 shape 包中的 Arrows 函数来实现:

library(shape)

plot(NA,NA, xlim=c(0,10), ylim=c(0,10))
Arrows(1,3,4,6,lwd=2, arr.type="triangle")
Arrows(5,7,6,9, arr.type="triangle", arr.width=0.5)

enter image description here

grid图形也有填充箭头。这是一个ggplot2的例子。type = "closed"会给出实心箭头。anglelength设置箭头的大小和形状:

library(ggplot2)

n=8
ggplot(mtcars[1:n,][order(mtcars$wt[1:n]),], aes(x=wt, y=mpg, xend=lead(wt), yend=lead(mpg))) +
  geom_segment(arrow=arrow(type="closed", 
                           angle=seq(10,80, length=n), 
                           length=unit(seq(8,4,length=n),"mm"))) 

enter image description here


3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接