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 :)
To create an arrow R, we can use plot function and arrows function. We just need to understand all the coordinate values that should be passed inside the arrows function. For example, if we have two vectors that contains values from 1 to 10 then the arrow can be created by using arrows function as arrows(1,1,10,10).
as explained in ?arrow
, you can use length
and angle
to change the appearance of standard arrows. With lwd
you can change the thickness, exactly like in lines(). Also lty
works, although the result is often not exactly nice.
A whole set of examples :
plot(c(0:10),type="n") arrows(1,0,2,1,length=0.2,angle=20) arrows(1,1,2,2,length=0.1,angle=40,lwd=3) invisible(mapply(arrows, rep(c(3,6),each=4),rep(3:6,2), rep(c(5,8),each=4),rep(5:8,2), angle=seq(10,40,length.out=8), length=rep(seq(0.1,0.3,length.out=4),2), lwd=rep(1:4,each=2)) )
Karline Soetaert's package shape
is useful for this purpose:
library(shape) plot(c(0,2),c(-2,2), col=NA) Arrows(c(0,1.7),c(1.3,-1.8),c(0.8,1.1),c(1.2,-1), lwd=2)
The default is a filled, curved arrowhead that's pleasant to look at:
Gotta love CRAN!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With