Can I use the arrow() function in R to plot a transparent arrow between two points that changes color? For example, an arrow that starts out as red at one point, and gradually changes to blue at the other point (both points are on the same row in a dataframe)? If so, how? And if not, is there another function that can do that in R?
Here is the piece of code I have until now, which draws points (blue and red) and connects the blue points with the red points with transparent blue arrows:
par(xpd=NA, mfrow=c(1,1), mar=c(4.25,3.2,6.20,3.55))
plot(data$x1,data$y1,col="red",pch=20,cex=0.6,xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)
plot(data$x2,data$y2,col="blue",pch=20,cex=0.6,xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)
plot(grid.picture(NLmap[-1]),xlim=c(xmin,xmax),ylim=c(ymin,ymax),axes=FALSE,ann=FALSE,xaxt='n',yaxt='n')
par(new=T)
points(data$x1,data$y1,col="red",pch=20,cex=0.25)
par(new=T)
points(data$x2,data$y2,col="blue",pch=20,cex=0.25)
par(new=T)
arrows(data$x1,data$y1, data$x2, data$y2, length = 0.05, angle = 30,
code = 2, col = "#9AC0CD40", lty = par("lty"), lwd = par("lwd"))
Hope this helps!